Rizin
unix-like reverse engineering framework and cli tools
rz_io.h File Reference
#include "rz_list.h"
#include <rz_util.h>
#include <rz_bind.h>
#include "rz_vector.h"
#include "rz_skyline.h"

Go to the source code of this file.

Classes

struct  rz_io_t
 
struct  rz_io_desc_t
 
struct  RzIODescData
 
struct  rz_io_plugin_t
 
struct  rz_io_map_t
 
struct  rz_io_cache_t
 
struct  rz_io_desc_cache_t
 
struct  rz_event_io_write_t
 
struct  rz_event_io_desc_close_t
 
struct  rz_event_io_map_del_t
 
struct  rz_io_bind_t
 

Macros

#define RZ_IO_SEEK_SET   0
 
#define RZ_IO_SEEK_CUR   1
 
#define RZ_IO_SEEK_END   2
 
#define rz_io_map_get_from(map)   map->itv.addr
 
#define rz_io_map_get_to(map)   (rz_itv_size(map->itv) ? rz_itv_end(map->itv) - 1 : 0)
 
#define RZ_IO_DESC_CACHE_SIZE   (sizeof(ut64) * 8)
 
#define rz_io_bind_init(x)   memset(&x, 0, sizeof(x))
 
#define rz_io_range_new()   RZ_NEW0(RzIORange)
 
#define rz_io_range_free(x)   free(x)
 

Typedefs

typedef struct rz_io_t RzIO
 
typedef struct rz_io_desc_t RzIODesc
 
typedef struct rz_io_plugin_t RzIOPlugin
 
typedef struct rz_io_map_t RzIOMap
 
typedef struct rz_io_cache_t RzIOCache
 
typedef struct rz_io_desc_cache_t RzIODescCache
 
typedef struct rz_event_io_write_t RzEventIOWrite
 
typedef struct rz_event_io_desc_close_t RzEventIODescClose
 
typedef struct rz_event_io_map_del_t RzEventIOMapDel
 
typedef int(* RzIOGetCurrentFd) (RzIO *io)
 
typedef bool(* RzIODescUse) (RzIO *io, int fd)
 
typedef RzIODesc *(* RzIODescGet) (RzIO *io, int fd)
 
typedef ut64(* RzIODescSize) (RzIODesc *desc)
 
typedef RzIODesc *(* RzIOOpen) (RzIO *io, const char *uri, int flags, int mode)
 
typedef RzIODesc *(* RzIOOpenAt) (RzIO *io, const char *uri, int flags, int mode, ut64 at, RZ_NULLABLE RZ_OUT RzIOMap **map)
 
typedef bool(* RzIOClose) (RzIO *io, int fd)
 
typedef bool(* RzIOReadAt) (RzIO *io, ut64 addr, ut8 *buf, int len)
 
typedef bool(* RzIOWriteAt) (RzIO *io, ut64 addr, const ut8 *buf, int len)
 
typedef char *(* RzIOSystem) (RzIO *io, const char *cmd)
 
typedef int(* RzIOFdOpen) (RzIO *io, const char *uri, int flags, int mode)
 
typedef bool(* RzIOFdClose) (RzIO *io, int fd)
 
typedef ut64(* RzIOFdSeek) (RzIO *io, int fd, ut64 addr, int whence)
 
typedef ut64(* RzIOFdSize) (RzIO *io, int fd)
 
typedef bool(* RzIOFdResize) (RzIO *io, int fd, ut64 newsize)
 
typedef ut64(* RzIOP2V) (RzIO *io, ut64 pa)
 
typedef ut64(* RzIOV2P) (RzIO *io, ut64 va)
 
typedef int(* RzIOFdRead) (RzIO *io, int fd, ut8 *buf, int len)
 
typedef int(* RzIOFdWrite) (RzIO *io, int fd, const ut8 *buf, int len)
 
typedef int(* RzIOFdReadAt) (RzIO *io, int fd, ut64 addr, ut8 *buf, int len)
 
typedef int(* RzIOFdWriteAt) (RzIO *io, int fd, ut64 addr, const ut8 *buf, int len)
 
typedef bool(* RzIOFdIsDbg) (RzIO *io, int fd)
 
typedef const char *(* RzIOFdGetName) (RzIO *io, int fd)
 
typedef RzList *(* RzIOFdGetMap) (RzIO *io, int fd)
 
typedef bool(* RzIOFdRemap) (RzIO *io, int fd, ut64 addr)
 
typedef ut8 *(* RzIOFdGetBuf) (RzIO *io, int fd, ut64 *size)
 
typedef bool(* RzIOIsValidOff) (RzIO *io, ut64 addr, int hasperm)
 
typedef RzIOMap *(* RzIOMapGet) (RzIO *io, ut64 addr)
 
typedef RzIOMap *(* RzIOMapGetPaddr) (RzIO *io, ut64 paddr)
 
typedef bool(* RzIOAddrIsMapped) (RzIO *io, ut64 addr)
 
typedef RzIOMap *(* RzIOMapAdd) (RzIO *io, int fd, int flags, ut64 delta, ut64 addr, ut64 size)
 
typedef struct rz_io_bind_t RzIOBind
 

Functions

 RZ_LIB_VERSION_HEADER (rz_io)
 
RZ_API RzIOMaprz_io_map_new (RzIO *io, int fd, int flags, ut64 delta, ut64 addr, ut64 size)
 
RZ_API void rz_io_map_init (RzIO *io)
 
RZ_API bool rz_io_map_remap (RzIO *io, ut32 id, ut64 addr)
 
RZ_API bool rz_io_map_remap_fd (RzIO *io, int fd, ut64 addr)
 
RZ_API ut64 rz_io_map_location (RzIO *io, ut64 size)
 Returns a memory location that can hold enough bytes without overlapping. More...
 
RZ_API bool rz_io_map_exists (RzIO *io, RzIOMap *map)
 
RZ_API bool rz_io_map_exists_for_id (RzIO *io, ut32 id)
 
RZ_API RzIOMaprz_io_map_resolve (RzIO *io, ut32 id)
 
RZ_API RzIOMaprz_io_map_add (RzIO *io, int fd, int flags, ut64 delta, ut64 addr, ut64 size)
 
RZ_API RzIOMaprz_io_map_add_batch (RzIO *io, int fd, int flags, ut64 delta, ut64 addr, ut64 size)
 
RZ_API RzIOMaprz_io_map_get (RzIO *io, ut64 addr)
 
RZ_API void rz_io_update (RzIO *io)
 
RZ_API bool rz_io_map_is_mapped (RzIO *io, ut64 addr)
 
RZ_API RzIOMaprz_io_map_get_paddr (RzIO *io, ut64 paddr)
 
RZ_API void rz_io_map_reset (RzIO *io)
 
RZ_API bool rz_io_map_del (RzIO *io, ut32 id)
 
RZ_API bool rz_io_map_del_for_fd (RzIO *io, int fd)
 
RZ_API bool rz_io_map_depriorize (RzIO *io, ut32 id)
 
RZ_API bool rz_io_map_priorize (RzIO *io, ut32 id)
 
RZ_API bool rz_io_map_priorize_for_fd (RzIO *io, int fd)
 
RZ_API void rz_io_map_cleanup (RzIO *io)
 
RZ_API void rz_io_map_fini (RzIO *io)
 
RZ_API void rz_io_map_set_name (RzIOMap *map, const char *name)
 
RZ_API void rz_io_map_del_name (RzIOMap *map)
 
RZ_API RzListrz_io_map_get_for_fd (RzIO *io, int fd)
 
RZ_API bool rz_io_map_resize (RzIO *io, ut32 id, ut64 newsize)
 
RZ_API RZ_BORROW RzPVectorrz_io_maps (RzIO *io)
 Returns the pointer to vector containing maps list. More...
 
RZ_API ut64 rz_io_map_next_available (RzIO *io, ut64 addr, ut64 size, ut64 load_align)
 
RZ_API ut64 rz_io_map_next_address (RzIO *io, ut64 addr)
 
RZ_API ut64 rz_io_p2v (RzIO *io, ut64 pa)
 
RZ_API ut64 rz_io_v2p (RzIO *io, ut64 va)
 
RZ_API RzIOrz_io_new (void)
 
RZ_API RzIOrz_io_init (RzIO *io)
 
RZ_API RzIODescrz_io_open_nomap (RzIO *io, const char *uri, int flags, int mode)
 
RZ_API RzIODescrz_io_open (RzIO *io, const char *uri, int flags, int mode)
 
RZ_API RzIODescrz_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. More...
 
RZ_API RzListrz_io_open_many (RzIO *io, const char *uri, int flags, int mode)
 
RZ_API RzIODescrz_io_open_buffer (RzIO *io, RzBuffer *b, int flags, int mode)
 
RZ_API bool rz_io_close (RzIO *io)
 
RZ_API bool rz_io_reopen (RzIO *io, int fd, int flags, int mode)
 
RZ_API int rz_io_close_all (RzIO *io)
 
RZ_API int rz_io_pread_at (RzIO *io, ut64 paddr, 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_vread_at_mapped (RzIO *io, ut64 vaddr, ut8 *buf, int len)
 
RZ_API bool rz_io_read_at (RzIO *io, ut64 addr, ut8 *buf, int len)
 
RZ_API bool rz_io_read_at_mapped (RzIO *io, ut64 addr, 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_at (RzIO *io, ut64 addr, const ut8 *buf, int len)
 
RZ_API bool rz_io_read (RzIO *io, ut8 *buf, int len)
 
RZ_API bool rz_io_write (RzIO *io, const ut8 *buf, int len)
 
RZ_API ut64 rz_io_size (RzIO *io)
 
RZ_API bool rz_io_is_listener (RzIO *io)
 
RZ_API char * rz_io_system (RzIO *io, const char *cmd)
 
RZ_API bool rz_io_resize (RzIO *io, ut64 newsize)
 
RZ_API bool rz_io_extend_at (RzIO *io, ut64 addr, ut64 size)
 Extend the RzIODesc at addr by inserting size 0 bytes. More...
 
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. More...
 
RZ_API void rz_io_bind (RzIO *io, RzIOBind *bnd)
 
RZ_API bool rz_io_shift (RzIO *io, ut64 start, ut64 end, st64 move)
 
RZ_API ut64 rz_io_seek (RzIO *io, ut64 offset, int whence)
 
RZ_API int rz_io_fini (RzIO *io)
 
RZ_API void rz_io_free (RzIO *io)
 
RZ_API bool rz_io_plugin_init (RzIO *io)
 
RZ_API bool rz_io_plugin_add (RzIO *io, RZ_BORROW RzIOPlugin *plugin)
 
RZ_API int rz_io_plugin_read (RzIODesc *desc, ut8 *buf, int len)
 
RZ_API int rz_io_plugin_write (RzIODesc *desc, const ut8 *buf, int len)
 
RZ_API int rz_io_plugin_read_at (RzIODesc *desc, ut64 addr, ut8 *buf, int len)
 
RZ_API int rz_io_plugin_write_at (RzIODesc *desc, ut64 addr, const ut8 *buf, int len)
 
RZ_API RzIOPluginrz_io_plugin_resolve (RzIO *io, const char *filename, bool many)
 
RZ_API RzIOPluginrz_io_plugin_get_default (RzIO *io, const char *filename, bool many)
 
RZ_API RzIODescrz_io_desc_new (RzIO *io, RzIOPlugin *plugin, const char *uri, int flags, int mode, void *data)
 
RZ_API RzIODescrz_io_desc_open (RzIO *io, const char *uri, int flags, int mode)
 
RZ_API RzIODescrz_io_desc_open_plugin (RzIO *io, RzIOPlugin *plugin, const char *uri, int flags, int mode)
 
RZ_API bool rz_io_desc_close (RzIODesc *desc)
 
RZ_API int rz_io_desc_read (RzIODesc *desc, ut8 *buf, int count)
 
RZ_API int rz_io_desc_write (RzIODesc *desc, const ut8 *buf, int count)
 
RZ_API void rz_io_desc_free (RzIODesc *desc)
 
RZ_API bool rz_io_desc_add (RzIO *io, RzIODesc *desc)
 
RZ_API bool rz_io_desc_del (RzIO *io, int fd)
 
RZ_API RzIODescrz_io_desc_get (RzIO *io, int fd)
 
RZ_API ut64 rz_io_desc_seek (RzIODesc *desc, ut64 offset, int whence)
 
RZ_API bool rz_io_desc_resize (RzIODesc *desc, ut64 newsize)
 
RZ_API ut64 rz_io_desc_size (RzIODesc *desc)
 
RZ_API ut8rz_io_desc_get_buf (RzIODesc *desc, RZ_OUT RZ_NONNULL ut64 *size)
 Returns the underlying buffer of the io descriptor. More...
 
RZ_API bool rz_io_desc_is_blockdevice (RzIODesc *desc)
 
RZ_API bool rz_io_desc_is_chardevice (RzIODesc *desc)
 
RZ_API bool rz_io_desc_exchange (RzIO *io, int fd, int fdx)
 
RZ_API bool rz_io_desc_is_dbg (RzIODesc *desc)
 
RZ_API int rz_io_desc_get_pid (RzIODesc *desc)
 
RZ_API int rz_io_desc_get_tid (RzIODesc *desc)
 
RZ_API bool rz_io_desc_get_base (RzIODesc *desc, ut64 *base)
 
RZ_API int rz_io_desc_read_at (RzIODesc *desc, ut64 addr, ut8 *buf, int len)
 
RZ_API int rz_io_desc_write_at (RzIODesc *desc, ut64 addr, const ut8 *buf, int len)
 
RZ_IPI bool rz_io_desc_init (RzIO *io)
 
RZ_IPI bool rz_io_desc_fini (RzIO *io)
 
RZ_API int rz_io_cache_invalidate (RzIO *io, ut64 from, ut64 to)
 
RZ_API bool rz_io_cache_at (RzIO *io, ut64 addr)
 
RZ_API void rz_io_cache_commit (RzIO *io, ut64 from, ut64 to)
 
RZ_API void rz_io_cache_init (RzIO *io)
 
RZ_API void rz_io_cache_fini (RzIO *io)
 
RZ_API void rz_io_cache_reset (RzIO *io, int set)
 
RZ_API bool rz_io_cache_write (RzIO *io, ut64 addr, const ut8 *buf, int len)
 
RZ_API bool rz_io_cache_read (RzIO *io, ut64 addr, ut8 *buf, int len)
 
RZ_API bool rz_io_desc_cache_init (RzIODesc *desc)
 
RZ_API int rz_io_desc_cache_write (RzIODesc *desc, ut64 paddr, const ut8 *buf, int len)
 
RZ_API int rz_io_desc_cache_read (RzIODesc *desc, ut64 paddr, ut8 *buf, int len)
 
RZ_API bool rz_io_desc_cache_commit (RzIODesc *desc)
 
RZ_API void rz_io_desc_cache_cleanup (RzIODesc *desc)
 
RZ_API void rz_io_desc_cache_fini (RzIODesc *desc)
 
RZ_API void rz_io_desc_cache_fini_all (RzIO *io)
 
RZ_API RzListrz_io_desc_cache_list (RzIODesc *desc)
 
RZ_API int rz_io_fd_open (RzIO *io, const char *uri, int flags, int mode)
 
RZ_API bool rz_io_fd_close (RzIO *io, int fd)
 
RZ_API int rz_io_fd_read (RzIO *io, int fd, ut8 *buf, int len)
 
RZ_API int rz_io_fd_write (RzIO *io, int fd, const ut8 *buf, int len)
 
RZ_API ut64 rz_io_fd_seek (RzIO *io, int fd, ut64 addr, int whence)
 
RZ_API ut64 rz_io_fd_size (RzIO *io, int fd)
 
RZ_API ut8rz_io_fd_get_buf (RzIO *io, int fd, RZ_OUT RZ_NONNULL ut64 *size)
 Returns the underlying buffer of the file descriptor. More...
 
RZ_API bool rz_io_fd_resize (RzIO *io, int fd, ut64 newsize)
 
RZ_API bool rz_io_fd_is_blockdevice (RzIO *io, int fd)
 
RZ_API bool rz_io_fd_is_chardevice (RzIO *io, int fd)
 
RZ_API int rz_io_fd_read_at (RzIO *io, int fd, 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)
 
RZ_API bool rz_io_fd_is_dbg (RzIO *io, int fd)
 
RZ_API int rz_io_fd_get_pid (RzIO *io, int fd)
 
RZ_API int rz_io_fd_get_tid (RzIO *io, int fd)
 
RZ_API bool rz_io_fd_get_base (RzIO *io, int fd, ut64 *base)
 
RZ_API const char * rz_io_fd_get_name (RzIO *io, int fd)
 
RZ_API int rz_io_fd_get_current (RzIO *io)
 
RZ_API int rz_io_fd_get_next (RzIO *io, int fd)
 
RZ_API int rz_io_fd_get_prev (RzIO *io, int fd)
 
RZ_API int rz_io_fd_get_highest (RzIO *io)
 
RZ_API int rz_io_fd_get_lowest (RzIO *io)
 
RZ_API bool rz_io_use_fd (RzIO *io, int fd)
 
RZ_API bool rz_io_is_valid_offset (RzIO *io, ut64 offset, int hasperm)
 
RZ_API bool rz_io_addr_is_mapped (RzIO *io, ut64 vaddr)
 
RZ_API bool rz_io_read_i (RzIO *io, ut64 addr, ut64 *val, int size, bool endian)
 
RZ_API bool rz_io_write_i (RzIO *io, ut64 addr, ut64 *val, int size, bool endian)
 

Variables

RzIOPlugin rz_io_plugin_procpid
 
RzIOPlugin rz_io_plugin_malloc
 
RzIOPlugin rz_io_plugin_sparse
 
RzIOPlugin rz_io_plugin_ptrace
 
RzIOPlugin rz_io_plugin_w32dbg
 
RzIOPlugin rz_io_plugin_windbg
 
RzIOPlugin rz_io_plugin_mach
 
RzIOPlugin rz_io_plugin_debug
 
RzIOPlugin rz_io_plugin_dmp
 
RzIOPlugin rz_io_plugin_shm
 
RzIOPlugin rz_io_plugin_gdb
 
RzIOPlugin rz_io_plugin_rap
 
RzIOPlugin rz_io_plugin_http
 
RzIOPlugin rz_io_plugin_bfdbg
 
RzIOPlugin rz_io_plugin_w32
 
RzIOPlugin rz_io_plugin_zip
 
RzIOPlugin rz_io_plugin_default
 
RzIOPlugin rz_io_plugin_ihex
 
RzIOPlugin rz_io_plugin_srec
 
RzIOPlugin rz_io_plugin_self
 
RzIOPlugin rz_io_plugin_gzip
 
RzIOPlugin rz_io_plugin_winkd
 
RzIOPlugin rz_io_plugin_rzpipe
 
RzIOPlugin rz_io_plugin_rzweb
 
RzIOPlugin rz_io_plugin_qnx
 
RzIOPlugin rz_io_plugin_rzk
 
RzIOPlugin rz_io_plugin_tcp
 
RzIOPlugin rz_io_plugin_bochs
 
RzIOPlugin rz_io_plugin_null
 
RzIOPlugin rz_io_plugin_ar
 
RzIOPlugin rz_io_plugin_winedbg
 
RzIOPlugin rz_io_plugin_gprobe
 
RzIOPlugin rz_io_plugin_fd
 

Macro Definition Documentation

◆ rz_io_bind_init

#define rz_io_bind_init (   x)    memset(&x, 0, sizeof(x))

Definition at line 344 of file rz_io.h.

◆ RZ_IO_DESC_CACHE_SIZE

#define RZ_IO_DESC_CACHE_SIZE   (sizeof(ut64) * 8)

Definition at line 169 of file rz_io.h.

◆ rz_io_map_get_from

#define rz_io_map_get_from (   map)    map->itv.addr

Definition at line 19 of file rz_io.h.

◆ rz_io_map_get_to

#define rz_io_map_get_to (   map)    (rz_itv_size(map->itv) ? rz_itv_end(map->itv) - 1 : 0)

Definition at line 20 of file rz_io.h.

◆ rz_io_range_free

#define rz_io_range_free (   x)    free(x)

Definition at line 430 of file rz_io.h.

◆ rz_io_range_new

#define rz_io_range_new ( )    RZ_NEW0(RzIORange)

Definition at line 429 of file rz_io.h.

◆ RZ_IO_SEEK_CUR

#define RZ_IO_SEEK_CUR   1

Definition at line 16 of file rz_io.h.

◆ RZ_IO_SEEK_END

#define RZ_IO_SEEK_END   2

Definition at line 17 of file rz_io.h.

◆ RZ_IO_SEEK_SET

#define RZ_IO_SEEK_SET   0

Definition at line 15 of file rz_io.h.

Typedef Documentation

◆ RzEventIODescClose

◆ RzEventIOMapDel

◆ RzEventIOWrite

◆ RzIO

typedef struct rz_io_t RzIO

◆ RzIOAddrIsMapped

typedef bool(* RzIOAddrIsMapped) (RzIO *io, ut64 addr)

Definition at line 220 of file rz_io.h.

◆ RzIOBind

typedef struct rz_io_bind_t RzIOBind

◆ RzIOCache

typedef struct rz_io_cache_t RzIOCache

◆ RzIOClose

typedef bool(* RzIOClose) (RzIO *io, int fd)

Definition at line 197 of file rz_io.h.

◆ RzIODesc

typedef struct rz_io_desc_t RzIODesc

◆ RzIODescCache

◆ RzIODescGet

typedef RzIODesc*(* RzIODescGet) (RzIO *io, int fd)

Definition at line 193 of file rz_io.h.

◆ RzIODescSize

typedef ut64(* RzIODescSize) (RzIODesc *desc)

Definition at line 194 of file rz_io.h.

◆ RzIODescUse

typedef bool(* RzIODescUse) (RzIO *io, int fd)

Definition at line 192 of file rz_io.h.

◆ RzIOFdClose

typedef bool(* RzIOFdClose) (RzIO *io, int fd)

Definition at line 202 of file rz_io.h.

◆ RzIOFdGetBuf

typedef ut8*(* RzIOFdGetBuf) (RzIO *io, int fd, ut64 *size)

Definition at line 216 of file rz_io.h.

◆ RzIOFdGetMap

typedef RzList*(* RzIOFdGetMap) (RzIO *io, int fd)

Definition at line 214 of file rz_io.h.

◆ RzIOFdGetName

typedef const char*(* RzIOFdGetName) (RzIO *io, int fd)

Definition at line 213 of file rz_io.h.

◆ RzIOFdIsDbg

typedef bool(* RzIOFdIsDbg) (RzIO *io, int fd)

Definition at line 212 of file rz_io.h.

◆ RzIOFdOpen

typedef int(* RzIOFdOpen) (RzIO *io, const char *uri, int flags, int mode)

Definition at line 201 of file rz_io.h.

◆ RzIOFdRead

typedef int(* RzIOFdRead) (RzIO *io, int fd, ut8 *buf, int len)

Definition at line 208 of file rz_io.h.

◆ RzIOFdReadAt

typedef int(* RzIOFdReadAt) (RzIO *io, int fd, ut64 addr, ut8 *buf, int len)

Definition at line 210 of file rz_io.h.

◆ RzIOFdRemap

typedef bool(* RzIOFdRemap) (RzIO *io, int fd, ut64 addr)

Definition at line 215 of file rz_io.h.

◆ RzIOFdResize

typedef bool(* RzIOFdResize) (RzIO *io, int fd, ut64 newsize)

Definition at line 205 of file rz_io.h.

◆ RzIOFdSeek

typedef ut64(* RzIOFdSeek) (RzIO *io, int fd, ut64 addr, int whence)

Definition at line 203 of file rz_io.h.

◆ RzIOFdSize

typedef ut64(* RzIOFdSize) (RzIO *io, int fd)

Definition at line 204 of file rz_io.h.

◆ RzIOFdWrite

typedef int(* RzIOFdWrite) (RzIO *io, int fd, const ut8 *buf, int len)

Definition at line 209 of file rz_io.h.

◆ RzIOFdWriteAt

typedef int(* RzIOFdWriteAt) (RzIO *io, int fd, ut64 addr, const ut8 *buf, int len)

Definition at line 211 of file rz_io.h.

◆ RzIOGetCurrentFd

typedef int(* RzIOGetCurrentFd) (RzIO *io)

Definition at line 191 of file rz_io.h.

◆ RzIOIsValidOff

typedef bool(* RzIOIsValidOff) (RzIO *io, ut64 addr, int hasperm)

Definition at line 217 of file rz_io.h.

◆ RzIOMap

typedef struct rz_io_map_t RzIOMap

◆ RzIOMapAdd

typedef RzIOMap*(* RzIOMapAdd) (RzIO *io, int fd, int flags, ut64 delta, ut64 addr, ut64 size)

Definition at line 221 of file rz_io.h.

◆ RzIOMapGet

typedef RzIOMap*(* RzIOMapGet) (RzIO *io, ut64 addr)

Definition at line 218 of file rz_io.h.

◆ RzIOMapGetPaddr

typedef RzIOMap*(* RzIOMapGetPaddr) (RzIO *io, ut64 paddr)

Definition at line 219 of file rz_io.h.

◆ RzIOOpen

typedef RzIODesc*(* RzIOOpen) (RzIO *io, const char *uri, int flags, int mode)

Definition at line 195 of file rz_io.h.

◆ RzIOOpenAt

typedef RzIODesc*(* RzIOOpenAt) (RzIO *io, const char *uri, int flags, int mode, ut64 at, RZ_NULLABLE RZ_OUT RzIOMap **map)

Definition at line 196 of file rz_io.h.

◆ RzIOP2V

typedef ut64(* RzIOP2V) (RzIO *io, ut64 pa)

Definition at line 206 of file rz_io.h.

◆ RzIOPlugin

typedef struct rz_io_plugin_t RzIOPlugin

◆ RzIOReadAt

typedef bool(* RzIOReadAt) (RzIO *io, ut64 addr, ut8 *buf, int len)

Definition at line 198 of file rz_io.h.

◆ RzIOSystem

typedef char*(* RzIOSystem) (RzIO *io, const char *cmd)

Definition at line 200 of file rz_io.h.

◆ RzIOV2P

typedef ut64(* RzIOV2P) (RzIO *io, ut64 va)

Definition at line 207 of file rz_io.h.

◆ RzIOWriteAt

typedef bool(* RzIOWriteAt) (RzIO *io, ut64 addr, const ut8 *buf, int len)

Definition at line 199 of file rz_io.h.

Function Documentation

◆ rz_io_addr_is_mapped()

RZ_API bool rz_io_addr_is_mapped ( RzIO io,
ut64  vaddr 
)

Definition at line 11 of file ioutils.c.

11  {
12  rz_return_val_if_fail(io, false);
13  return (io->va && rz_io_map_get(io, vaddr));
14 }
#define rz_return_val_if_fail(expr, val)
Definition: rz_assert.h:108
RZ_API RzIOMap * rz_io_map_get(RzIO *io, ut64 addr)
Definition: io_map.c:176
int va
Definition: rz_io.h:63

References rz_io_map_get(), rz_return_val_if_fail, and rz_io_t::va.

Referenced by rz_io_bind().

◆ rz_io_bind()

RZ_API void rz_io_bind ( RzIO io,
RzIOBind bnd 
)

Definition at line 550 of file io.c.

550  {
551  rz_return_if_fail(io && bnd);
552 
553  bnd->io = io;
554  bnd->init = true;
556  bnd->desc_use = rz_io_use_fd;
557  bnd->desc_get = rz_io_desc_get;
558  bnd->desc_size = rz_io_desc_size;
559  bnd->p2v = rz_io_p2v;
560  bnd->v2p = rz_io_v2p;
561  bnd->open = rz_io_open_nomap;
562  bnd->open_at = rz_io_open_at;
563  bnd->close = rz_io_fd_close;
564  bnd->read_at = rz_io_read_at;
565  bnd->write_at = rz_io_write_at;
566  bnd->system = rz_io_system;
567  bnd->fd_open = rz_io_fd_open;
568  bnd->fd_close = rz_io_fd_close;
569  bnd->fd_seek = rz_io_fd_seek;
570  bnd->fd_size = rz_io_fd_size;
571  bnd->fd_resize = rz_io_fd_resize;
572  bnd->fd_read = rz_io_fd_read;
573  bnd->fd_write = rz_io_fd_write;
576  bnd->fd_is_dbg = rz_io_fd_is_dbg;
582  bnd->map_get = rz_io_map_get;
585  bnd->map_add = rz_io_map_add;
586 #if HAVE_PTRACE
587  bnd->ptrace = rz_io_ptrace;
588  bnd->ptrace_func = rz_io_ptrace_func;
589 #endif
590 #if __WINDOWS__
591  bnd->get_w32dbg_wrap = rz_io_get_w32dbg_wrap;
592 #endif
593 }
RZ_API char * rz_io_system(RzIO *io, const char *cmd)
Definition: io.c:411
RZ_API RzIODesc * rz_io_open_nomap(RzIO *io, const char *uri, int perm, int mode)
Definition: io.c:145
RZ_API bool rz_io_read_at(RzIO *io, ut64 addr, ut8 *buf, int len)
Definition: io.c:300
RZ_API ut64 rz_io_v2p(RzIO *io, ut64 va)
Definition: io.c:541
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.
Definition: io.c:177
RZ_API ut64 rz_io_p2v(RzIO *io, ut64 pa)
Definition: io.c:533
RZ_API bool rz_io_write_at(RzIO *io, ut64 addr, const ut8 *buf, int len)
Definition: io.c:358
#define rz_return_if_fail(expr)
Definition: rz_assert.h:100
RZ_API bool rz_io_fd_resize(RzIO *io, int fd, ut64 newsize)
Definition: io_fd.c:58
RZ_API bool rz_io_fd_is_dbg(RzIO *io, int fd)
Definition: io_fd.c:86
RZ_API ut64 rz_io_fd_size(RzIO *io, int fd)
Definition: io_fd.c:42
RZ_API const char * rz_io_fd_get_name(RzIO *io, int fd)
Definition: io_fd.c:112
RZ_API bool rz_io_addr_is_mapped(RzIO *io, ut64 vaddr)
Definition: ioutils.c:11
RZ_API int rz_io_fd_open(RzIO *io, const char *uri, int flags, int mode)
Definition: io_fd.c:6
RZ_API bool rz_io_map_remap_fd(RzIO *io, int fd, ut64 addr)
Definition: io_map.c:69
RZ_API ut64 rz_io_desc_size(RzIODesc *desc)
Definition: io_desc.c:224
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.
Definition: io_fd.c:53
RZ_API int rz_io_fd_read(RzIO *io, int fd, ut8 *buf, int len)
Definition: io_fd.c:16
RZ_API int rz_io_fd_read_at(RzIO *io, int fd, ut64 addr, ut8 *buf, int len)
Definition: io_fd.c:71
RZ_API RzIOMap * rz_io_map_get_paddr(RzIO *io, ut64 paddr)
Definition: io_map.c:163
RZ_API RzIODesc * rz_io_desc_get(RzIO *io, int fd)
Definition: io_desc.c:73
RZ_API RzList * rz_io_map_get_for_fd(RzIO *io, int fd)
Definition: io_map.c:388
RZ_API int rz_io_fd_write_at(RzIO *io, int fd, ut64 addr, const ut8 *buf, int len)
Definition: io_fd.c:80
RZ_API bool rz_io_is_valid_offset(RzIO *io, ut64 offset, int hasperm)
Definition: ioutils.c:20
RZ_API int rz_io_fd_write(RzIO *io, int fd, const ut8 *buf, int len)
Definition: io_fd.c:26
RZ_API int rz_io_fd_get_current(RzIO *io)
Definition: io_fd.c:135
RZ_API ut64 rz_io_fd_seek(RzIO *io, int fd, ut64 addr, int whence)
Definition: io_fd.c:35
RZ_API bool rz_io_use_fd(RzIO *io, int fd)
Definition: io_fd.c:118
RZ_API RzIOMap * rz_io_map_add(RzIO *io, int fd, int flags, ut64 delta, ut64 addr, ut64 size)
Definition: io_map.c:151
RZ_API bool rz_io_fd_close(RzIO *io, int fd)
Definition: io_fd.c:11
RzIOFdResize fd_resize
Definition: rz_io.h:247
RzIOOpen open
Definition: rz_io.h:237
RzIOReadAt read_at
Definition: rz_io.h:240
RzIOIsValidOff is_valid_offset
Definition: rz_io.h:257
RzIOFdOpen fd_open
Definition: rz_io.h:243
RzIOClose close
Definition: rz_io.h:239
RzIOV2P v2p
Definition: rz_io.h:262
RzIOMapGet map_get
Definition: rz_io.h:259
RzIOP2V p2v
Definition: rz_io.h:263
RzIODescSize desc_size
Definition: rz_io.h:236
RzIOAddrIsMapped addr_is_mapped
Definition: rz_io.h:258
RzIOSystem system
Definition: rz_io.h:242
RzIOMapAdd map_add
Definition: rz_io.h:261
RzIODescUse desc_use
Definition: rz_io.h:234
RzIOOpenAt open_at
Definition: rz_io.h:238
RzIOGetCurrentFd fd_get_current
Definition: rz_io.h:233
RzIOFdSeek fd_seek
Definition: rz_io.h:245
RzIOWriteAt write_at
Definition: rz_io.h:241
RzIOFdGetBuf fd_getbuf
Definition: rz_io.h:256
RzIO * io
Definition: rz_io.h:232
RzIOFdWrite fd_write
Definition: rz_io.h:249
RzIOFdGetMap fd_get_map
Definition: rz_io.h:254
RzIOFdIsDbg fd_is_dbg
Definition: rz_io.h:252
RzIOFdReadAt fd_read_at
Definition: rz_io.h:250
RzIOFdClose fd_close
Definition: rz_io.h:244
RzIOFdGetName fd_get_name
Definition: rz_io.h:253
RzIOFdRemap fd_remap
Definition: rz_io.h:255
RzIOFdWriteAt fd_write_at
Definition: rz_io.h:251
RzIOFdSize fd_size
Definition: rz_io.h:246
RzIOFdRead fd_read
Definition: rz_io.h:248
RzIOMapGetPaddr map_get_paddr
Definition: rz_io.h:260
int init
Definition: rz_io.h:231
RzIODescGet desc_get
Definition: rz_io.h:235

References rz_io_bind_t::addr_is_mapped, rz_io_bind_t::close, rz_io_bind_t::desc_get, rz_io_bind_t::desc_size, rz_io_bind_t::desc_use, rz_io_bind_t::fd_close, rz_io_bind_t::fd_get_current, rz_io_bind_t::fd_get_map, rz_io_bind_t::fd_get_name, rz_io_bind_t::fd_getbuf, rz_io_bind_t::fd_is_dbg, rz_io_bind_t::fd_open, rz_io_bind_t::fd_read, rz_io_bind_t::fd_read_at, rz_io_bind_t::fd_remap, rz_io_bind_t::fd_resize, rz_io_bind_t::fd_seek, rz_io_bind_t::fd_size, rz_io_bind_t::fd_write, rz_io_bind_t::fd_write_at, rz_io_bind_t::init, rz_io_bind_t::io, rz_io_bind_t::is_valid_offset, rz_io_bind_t::map_add, rz_io_bind_t::map_get, rz_io_bind_t::map_get_paddr, rz_io_bind_t::open, rz_io_bind_t::open_at, rz_io_bind_t::p2v, rz_io_bind_t::read_at, rz_io_addr_is_mapped(), rz_io_desc_get(), rz_io_desc_size(), rz_io_fd_close(), rz_io_fd_get_buf(), rz_io_fd_get_current(), rz_io_fd_get_name(), rz_io_fd_is_dbg(), rz_io_fd_open(), rz_io_fd_read(), rz_io_fd_read_at(), rz_io_fd_resize(), rz_io_fd_seek(), rz_io_fd_size(), rz_io_fd_write(), rz_io_fd_write_at(), rz_io_is_valid_offset(), rz_io_map_add(), rz_io_map_get(), rz_io_map_get_for_fd(), rz_io_map_get_paddr(), rz_io_map_remap_fd(), rz_io_open_at(), rz_io_open_nomap(), rz_io_p2v(), rz_io_read_at(), rz_io_system(), rz_io_use_fd(), rz_io_v2p(), rz_io_write_at(), rz_return_if_fail, rz_io_bind_t::system, rz_io_bind_t::v2p, and rz_io_bind_t::write_at.

Referenced by __open(), download_pdb(), rz_core_file_reopen(), rz_core_init(), rz_diff_file_open(), and rzfind_open_file().

◆ rz_io_cache_at()

RZ_API bool rz_io_cache_at ( RzIO io,
ut64  addr 
)

Definition at line 16 of file io_cache.c.

16  {
17  rz_return_val_if_fail(io, false);
19 }
static bool rz_skyline_contains(RzSkyline *skyline, ut64 addr)
Definition: rz_skyline.h:51
RzSkyline cache_skyline
Definition: rz_io.h:77
static int addr
Definition: z80asm.c:58

References addr, rz_io_t::cache_skyline, rz_return_val_if_fail, and rz_skyline_contains().

Referenced by rz_io_desc_read().

◆ rz_io_cache_commit()

RZ_API void rz_io_cache_commit ( RzIO io,
ut64  from,
ut64  to 
)

Definition at line 35 of file io_cache.c.

35  {
36  void **iter;
37  RzIOCache *c;
40  rz_pvector_foreach (&io->cache, iter) {
41  // if (from <= c->to - 1 && c->from <= to - 1) {
42  c = *iter;
43  if (rz_itv_overlap(c->itv, range)) {
44  int cached = io->cached;
45  io->cached = 0;
46  if (rz_io_write_at(io, rz_itv_begin(c->itv), c->data, rz_itv_size(c->itv))) {
47  c->written = true;
48  } else {
49  eprintf("Error writing change at 0x%08" PFMT64x "\n", rz_itv_begin(c->itv));
50  }
51  io->cached = cached;
52  // break; // XXX old behavior, revisit this
53  }
54  }
55 }
#define eprintf(x, y...)
Definition: rlcc.c:7
RZ_API bool rz_io_write_at(RzIO *io, ut64 addr, const ut8 *buf, int len)
Definition: io.c:358
static ut64 rz_itv_begin(RzInterval itv)
Definition: rz_itv.h:34
struct rz_interval_t RzInterval
static bool rz_itv_overlap(RzInterval itv, RzInterval x)
Definition: rz_itv.h:64
static ut64 rz_itv_size(RzInterval itv)
Definition: rz_itv.h:38
#define PFMT64x
Definition: rz_types.h:393
#define rz_pvector_foreach(vec, it)
Definition: rz_vector.h:334
static struct sockaddr static addrlen static backlog const void static flags void struct sockaddr from
Definition: sfsocketcall.h:123
static struct sockaddr static addrlen static backlog const void static flags void struct sockaddr socklen_t static fromlen const void const struct sockaddr to
Definition: sfsocketcall.h:125
#define c(i)
Definition: sha256.c:43
int cached
Definition: rz_io.h:69
RzPVector cache
Definition: rz_io.h:76

References c, rz_io_t::cache, rz_io_t::cached, eprintf, from, PFMT64x, capstone::range, rz_io_write_at(), rz_itv_begin(), rz_itv_overlap(), rz_itv_size(), rz_pvector_foreach, rz_return_if_fail, and to.

Referenced by rz_write_cache_commit_all_handler(), and rz_write_cache_commit_handler().

◆ rz_io_cache_fini()

RZ_API void rz_io_cache_fini ( RzIO io)

Definition at line 28 of file io_cache.c.

28  {
30  rz_pvector_fini(&io->cache);
32  io->cached = 0;
33 }
static void rz_skyline_fini(RzSkyline *skyline)
Definition: rz_skyline.h:24
RZ_API void rz_pvector_fini(RzPVector *vec)
Definition: vector.c:331

References rz_io_t::cache, rz_io_t::cache_skyline, rz_io_t::cached, rz_pvector_fini(), rz_return_if_fail, and rz_skyline_fini().

Referenced by rz_core_disasm_pde(), rz_io_close_all(), and rz_io_fini().

◆ rz_io_cache_init()

RZ_API void rz_io_cache_init ( RzIO io)

Definition at line 21 of file io_cache.c.

21  {
25  io->cached = 0;
26 }
static void cache_item_free(RzIOCache *cache)
Definition: io_cache.c:7
static void rz_skyline_init(RzSkyline *skyline)
Definition: rz_skyline.h:19
RZ_API void rz_pvector_init(RzPVector *vec, RzPVectorFree free)
Definition: vector.c:298
void(* RzPVectorFree)(void *e)
Definition: rz_vector.h:43

References rz_io_t::cache, cache_item_free(), rz_io_t::cache_skyline, rz_io_t::cached, rz_pvector_init(), rz_return_if_fail, and rz_skyline_init().

Referenced by rz_core_disasm_pde(), and rz_io_init().

◆ rz_io_cache_invalidate()

RZ_API int rz_io_cache_invalidate ( RzIO io,
ut64  from,
ut64  to 
)

Definition at line 64 of file io_cache.c.

64  {
65  rz_return_val_if_fail(io, 0);
66  int invalidated = 0;
67  void **iter;
68  RzIOCache *c;
71  c = *iter;
72  if (rz_itv_overlap(c->itv, range)) {
73  int cached = io->cached;
74  io->cached = 0;
75  rz_io_write_at(io, rz_itv_begin(c->itv), c->odata, rz_itv_size(c->itv));
76  io->cached = cached;
77  c->written = false;
79  free(c->data);
80  free(c->odata);
81  free(c);
82  invalidated++;
83  }
84  }
86  rz_pvector_foreach (&io->cache, iter) {
87  c = *iter;
88  rz_skyline_add(&io->cache_skyline, c->itv, c);
89  }
90  return invalidated;
91 }
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130
static void rz_skyline_clear(RzSkyline *skyline)
Definition: rz_skyline.h:29
RZ_API bool rz_skyline_add(RzSkyline *skyline, RzInterval itv, void *user)
Definition: skyline.c:12
RZ_API void rz_pvector_remove_data(RzPVector *vec, void *x)
Definition: vector.c:362
#define rz_pvector_foreach_prev(vec, it)
Definition: rz_vector.h:338

References c, rz_io_t::cache, rz_io_t::cache_skyline, rz_io_t::cached, free(), from, capstone::range, rz_io_write_at(), rz_itv_begin(), rz_itv_overlap(), rz_itv_size(), rz_pvector_foreach, rz_pvector_foreach_prev, rz_pvector_remove_data(), rz_return_val_if_fail, rz_skyline_add(), rz_skyline_clear(), and to.

Referenced by rz_write_cache_remove_handler().

◆ rz_io_cache_read()

RZ_API bool rz_io_cache_read ( RzIO io,
ut64  addr,
ut8 buf,
int  len 
)

Definition at line 131 of file io_cache.c.

131  {
132  rz_return_val_if_fail(io && buf, false);
133  RzSkyline *skyline = &io->cache_skyline;
134  if (!len) {
135  return true;
136  }
137  if (UT64_ADD_OVFCHK(addr, len)) {
138  const ut64 first_len = UT64_MAX - addr;
139  rz_io_cache_read(io, 0, buf + first_len, len - first_len);
140  len = first_len;
141  }
143  if (!iter) {
144  return false;
145  }
146  const RzSkylineItem *last = (RzSkylineItem *)skyline->v.a + skyline->v.len;
147  bool covered = false;
148  while (iter != last) {
149  const ut64 begin = rz_itv_begin(iter->itv);
150  const st64 addr_offset = begin - addr;
151  const ut64 buf_offset = addr_offset > 0 ? addr_offset : 0;
152  const ut64 cur_addr = addr + buf_offset;
153  const ut64 left = len - buf_offset;
154  if (begin > cur_addr + left) {
155  break;
156  }
157  RzIOCache *cache = iter->user;
158  const ut64 cache_shift = addr_offset < 0 ? -addr_offset : 0;
159  const ut64 cache_offset = begin - rz_itv_begin(cache->itv) + cache_shift;
160  const ut64 read = RZ_MIN(left, rz_itv_size(iter->itv) - cache_shift);
161  memcpy(buf + buf_offset, cache->data + cache_offset, read);
162  covered = true;
163  if (left - read <= 0) {
164  break;
165  }
166  iter++;
167  }
168  return covered;
169 }
size_t len
Definition: 6502dis.c:15
RZ_API bool rz_io_cache_read(RzIO *io, ut64 addr, ut8 *buf, int len)
Definition: io_cache.c:131
voidpf void * buf
Definition: ioapi.h:138
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
while(len< limit &&buf1[len]==buf2[len])++len
RZ_API const RzSkylineItem * rz_skyline_get_item_intersect(RzSkyline *skyline, ut64 addr, ut64 len)
Definition: skyline.c:60
#define RZ_MIN(x, y)
#define st64
Definition: rz_types_base.h:10
#define UT64_MAX
Definition: rz_types_base.h:86
#define UT64_ADD_OVFCHK(x, y)
RzInterval itv
Definition: rz_io.h:163
ut8 * data
Definition: rz_io.h:164
RzVector v
Definition: rz_skyline.h:13
void * a
Definition: rz_vector.h:46
size_t len
Definition: rz_vector.h:47
ut64(WINAPI *w32_GetEnabledXStateFeatures)()
int read(izstream &zs, T *x, Items items)
Definition: zstream.h:115

References rz_vector_t::a, addr, rz_io_t::cache_skyline, rz_io_cache_t::data, rz_io_cache_t::itv, len, rz_vector_t::len, memcpy(), read(), rz_io_cache_read(), rz_itv_begin(), rz_itv_size(), RZ_MIN, rz_return_val_if_fail, rz_skyline_get_item_intersect(), st64, ut64(), UT64_ADD_OVFCHK, UT64_MAX, rz_skyline_t::v, and while().

Referenced by rz_io_cache_read(), rz_io_desc_read(), rz_io_nread_at(), rz_io_read_at(), and rz_io_read_at_mapped().

◆ rz_io_cache_reset()

RZ_API void rz_io_cache_reset ( RzIO io,
int  set 
)

Definition at line 57 of file io_cache.c.

57  {
59  io->cached = set;
60  rz_pvector_clear(&io->cache);
62 }
RZ_API void rz_pvector_clear(RzPVector *vec)
Definition: vector.c:326

References rz_io_t::cache, rz_io_t::cache_skyline, rz_io_t::cached, rz_pvector_clear(), rz_return_if_fail, and rz_skyline_clear().

Referenced by rz_core_link_stroff(), and rz_write_cache_remove_all_handler().

◆ rz_io_cache_write()

RZ_API bool rz_io_cache_write ( RzIO io,
ut64  addr,
const ut8 buf,
int  len 
)

Definition at line 93 of file io_cache.c.

93  {
94  rz_return_val_if_fail(io && buf, false);
96  if (!ch) {
97  return false;
98  }
99  if (UT64_ADD_OVFCHK(addr, len)) {
100  const ut64 first_len = UT64_MAX - addr;
101  rz_io_cache_write(io, 0, buf + first_len, len - first_len);
102  len = first_len;
103  }
104  ch->itv = (RzInterval){ addr, len };
105  ch->odata = (ut8 *)calloc(1, len + 1);
106  if (!ch->odata) {
107  free(ch);
108  return false;
109  }
110  ch->data = (ut8 *)calloc(1, len + 1);
111  if (!ch->data) {
112  free(ch->odata);
113  free(ch);
114  return false;
115  }
116  ch->written = false;
117  {
118  const bool cm = io->cachemode;
119  io->cachemode = false;
120  rz_io_read_at(io, addr, ch->odata, len);
121  io->cachemode = cm;
122  }
123  memcpy(ch->data, buf, len);
124  rz_pvector_push(&io->cache, ch);
125  rz_skyline_add(&io->cache_skyline, ch->itv, ch);
126  RzEventIOWrite iow = { addr, buf, len };
128  return true;
129 }
RZ_API bool rz_io_cache_write(RzIO *io, ut64 addr, const ut8 *buf, int len)
Definition: io_cache.c:93
uint8_t ut8
Definition: lh5801.h:11
void * calloc(size_t number, size_t size)
Definition: malloc.c:102
RZ_API void rz_event_send(RzEvent *ev, int type, void *data)
Definition: event.c:115
@ RZ_EVENT_IO_WRITE
Definition: rz_event.h:42
RZ_API bool rz_io_read_at(RzIO *io, ut64 addr, ut8 *buf, int len)
Definition: io.c:300
#define RZ_NEW0(x)
Definition: rz_types.h:284
static void ** rz_pvector_push(RzPVector *vec, void *x)
Definition: rz_vector.h:300
int written
Definition: rz_io.h:166
ut8 * odata
Definition: rz_io.h:165
bool cachemode
Definition: rz_io.h:70
RzEvent * event
Definition: rz_io.h:90

References addr, rz_io_t::cache, rz_io_t::cache_skyline, rz_io_t::cachemode, calloc(), rz_io_cache_t::data, rz_io_t::event, free(), rz_io_cache_t::itv, len, memcpy(), rz_io_cache_t::odata, RZ_EVENT_IO_WRITE, rz_event_send(), rz_io_cache_write(), rz_io_read_at(), RZ_NEW0, rz_pvector_push(), rz_return_val_if_fail, rz_skyline_add(), ut64(), UT64_ADD_OVFCHK, UT64_MAX, and rz_io_cache_t::written.

Referenced by rz_io_cache_write(), rz_io_desc_read(), and rz_io_write_at().

◆ rz_io_close()

RZ_API bool rz_io_close ( RzIO io)

Definition at line 441 of file io.c.

441  {
442  return io ? rz_io_desc_close(io->desc) : false;
443 }
#define false
RZ_API bool rz_io_desc_close(RzIODesc *desc)
Definition: io_desc.c:165
struct rz_io_desc_t * desc
Definition: rz_io.h:60

References rz_io_t::desc, and rz_io_desc_close().

◆ rz_io_close_all()

RZ_API int rz_io_close_all ( RzIO io)

Definition at line 258 of file io.c.

258  { // what about undo?
259  if (!io) {
260  return false;
261  }
262  rz_io_desc_fini(io);
263  rz_io_map_reset(io);
264  rz_io_desc_init(io);
265  rz_io_cache_fini(io);
266  return true;
267 }
RZ_IPI bool rz_io_desc_init(RzIO *io)
Definition: io_desc.c:368
RZ_API void rz_io_map_reset(RzIO *io)
Definition: io_map.c:186
RZ_API void rz_io_cache_fini(RzIO *io)
Definition: io_cache.c:28
RZ_IPI bool rz_io_desc_fini(RzIO *io)
Definition: io_desc.c:390

References rz_io_cache_fini(), rz_io_desc_fini(), rz_io_desc_init(), and rz_io_map_reset().

Referenced by __close_file_cb(), file_load(), rz_core_io_file_open(), and rz_open_close_all_handler().

◆ rz_io_desc_add()

RZ_API bool rz_io_desc_add ( RzIO io,
RzIODesc desc 
)

Definition at line 49 of file io_desc.c.

49  {
50  rz_return_val_if_fail(io && desc && desc->io, false);
51  if (!rz_id_storage_set(io->files, desc, desc->fd)) {
52  // TODO: use assert here
53  eprintf("You are using this API incorrectly\n");
54  eprintf("fd %d was probably not generated by this RzIO-instance\n", desc->fd);
56  return false;
57  }
58  return true;
59 }
const char * desc
Definition: bin_vsf.c:19
RZ_API bool rz_id_storage_set(RzIDStorage *storage, void *data, ut32 id)
Definition: idpool.c:131
RZ_API char RZ_API void rz_sys_backtrace(void)
Print the backtrace at the point this function is called from.
Definition: sys.c:265
RzIDStorage * files
Definition: rz_io.h:75

References desc, eprintf, rz_io_t::files, rz_id_storage_set(), rz_return_val_if_fail, and rz_sys_backtrace().

Referenced by find_apk_binary(), rz_core_file_open_many(), rz_io_desc_open(), rz_io_desc_open_plugin(), and rz_io_open_many().

◆ rz_io_desc_cache_cleanup()

RZ_API void rz_io_desc_cache_cleanup ( RzIODesc desc)

Definition at line 343 of file p_cache.c.

343  {
344  if (desc && desc->cache) {
345  ht_up_foreach(desc->cache, __desc_cache_cleanup_cb, desc);
346  }
347 }
static bool __desc_cache_cleanup_cb(void *user, const ut64 k, const void *v)
Definition: p_cache.c:321

References __desc_cache_cleanup_cb(), and desc.

Referenced by rz_io_desc_exchange(), and rz_io_desc_resize().

◆ rz_io_desc_cache_commit()

RZ_API bool rz_io_desc_cache_commit ( RzIODesc desc)

Definition at line 302 of file p_cache.c.

302  {
303  RzIODesc *current;
304  if (!desc || !(desc->perm & RZ_PERM_W) || !desc->io || !desc->io->files || !desc->io->p_cache) {
305  return false;
306  }
307  if (!desc->cache) {
308  return true;
309  }
310  current = desc->io->desc;
311  desc->io->desc = desc;
312  desc->io->p_cache = false;
313  ht_up_foreach(desc->cache, __desc_cache_commit_cb, desc);
314  ht_up_free(desc->cache);
315  desc->cache = NULL;
316  desc->io->p_cache = true;
317  desc->io->desc = current;
318  return true;
319 }
#define NULL
Definition: cris-opc.c:27
static bool __desc_cache_commit_cb(void *user, const ut64 k, const void *v)
Definition: p_cache.c:278
#define RZ_PERM_W
Definition: rz_types.h:94

References __desc_cache_commit_cb(), desc, NULL, and RZ_PERM_W.

Referenced by rz_write_pcache_commit_handler().

◆ rz_io_desc_cache_fini()

RZ_API void rz_io_desc_cache_fini ( RzIODesc desc)

Definition at line 358 of file p_cache.c.

358  {
359  __desc_fini_cb(NULL, (void *)desc, 0);
360 }
static bool __desc_fini_cb(void *user, void *data, ut32 id)
Definition: p_cache.c:349

References __desc_fini_cb(), desc, and NULL.

Referenced by rz_io_desc_free().

◆ rz_io_desc_cache_fini_all()

RZ_API void rz_io_desc_cache_fini_all ( RzIO io)

Definition at line 362 of file p_cache.c.

362  {
363  if (io && io->files) {
365  }
366 }
RZ_API bool rz_id_storage_foreach(RzIDStorage *storage, RzIDStorageForeachCb cb, void *user)
Definition: idpool.c:254

References __desc_fini_cb(), rz_io_t::files, NULL, and rz_id_storage_foreach().

Referenced by cb_iopcache(), cb_iopcacheread(), cb_iopcachewrite(), and rz_io_fini().

◆ rz_io_desc_cache_init()

RZ_API bool rz_io_desc_cache_init ( RzIODesc desc)

Definition at line 79 of file p_cache.c.

79  {
80  if (!desc || desc->cache) {
81  return false;
82  }
83  return (desc->cache = ht_up_new(NULL, pcache_kv_free, NULL)) ? true : false;
84 }
#define true
static void pcache_kv_free(HtUPKv *kv)
Definition: p_cache.c:75

References desc, NULL, pcache_kv_free(), and true.

Referenced by rz_io_desc_cache_write().

◆ rz_io_desc_cache_list()

RZ_API RzList* rz_io_desc_cache_list ( RzIODesc desc)

Definition at line 249 of file p_cache.c.

249  {
250  if (!desc || !desc->io || !desc->io->desc || !desc->io->p_cache || !desc->cache) {
251  return NULL;
252  }
254  if (!writes) {
255  return NULL;
256  }
257  ht_up_foreach(desc->cache, __desc_cache_list_cb, writes);
258  RzIODesc *current = desc->io->desc;
259  desc->io->desc = desc;
260  desc->io->p_cache = false;
261 
262  RzIOCache *c;
263  RzListIter *iter;
264  rz_list_foreach (writes, iter, c) {
265  const ut64 itvSize = rz_itv_size(c->itv);
266  c->odata = calloc(1, itvSize);
267  if (!c->odata) {
268  rz_list_free(writes);
269  return NULL;
270  }
271  rz_io_pread_at(desc->io, rz_itv_begin(c->itv), c->odata, itvSize);
272  }
273  desc->io->p_cache = true;
274  desc->io->desc = current;
275  return writes;
276 }
RZ_API RZ_OWN RzList * rz_list_newf(RzListFree f)
Returns a new initialized RzList pointer and sets the free method.
Definition: list.c:248
RZ_API void rz_list_free(RZ_NONNULL RzList *list)
Empties the list and frees the list pointer.
Definition: list.c:137
static bool __desc_cache_list_cb(void *user, const ut64 k, const void *v)
Definition: p_cache.c:199
static void __riocache_free(void *user)
Definition: p_cache.c:190
RZ_API int rz_io_pread_at(RzIO *io, ut64 paddr, ut8 *buf, int len)
Definition: io.c:269
void(* RzListFree)(void *ptr)
Definition: rz_list.h:11

References __desc_cache_list_cb(), __riocache_free(), c, calloc(), desc, NULL, rz_io_pread_at(), rz_itv_begin(), rz_itv_size(), rz_list_free(), rz_list_newf(), and ut64().

Referenced by rz_core_io_pcache_print().

◆ rz_io_desc_cache_read()

RZ_API int rz_io_desc_cache_read ( RzIODesc desc,
ut64  paddr,
ut8 buf,
int  len 
)

Definition at line 142 of file p_cache.c.

142  {
143  RzIODescCache *cache;
144  ut8 *ptr = buf;
145  ut64 caddr, desc_sz = rz_io_desc_size(desc);
146  int cbaddr, amount = 0;
147  if ((len < 1) || !desc || (desc_sz <= paddr) || !desc->io || !desc->cache) {
148  return 0;
149  }
150  if (len > desc_sz) {
151  len = (int)desc_sz;
152  }
153  if (paddr > (desc_sz - len)) {
154  len = (int)(desc_sz - paddr);
155  }
156  caddr = paddr / RZ_IO_DESC_CACHE_SIZE;
157  cbaddr = paddr % RZ_IO_DESC_CACHE_SIZE;
158  while (amount < len) {
159  // get an existing desc-cache, if it exists
160  if (!(cache = (RzIODescCache *)ht_up_find(desc->cache, caddr, NULL))) {
161  amount += (RZ_IO_DESC_CACHE_SIZE - cbaddr);
162  ptr += (RZ_IO_DESC_CACHE_SIZE - cbaddr);
163  goto beach;
164  }
165  if ((len - amount) > (RZ_IO_DESC_CACHE_SIZE - cbaddr)) {
166  amount += (RZ_IO_DESC_CACHE_SIZE - cbaddr);
167  for (; cbaddr < RZ_IO_DESC_CACHE_SIZE; cbaddr++) {
168  if (cache->cached & (0x1ULL << cbaddr)) {
169  *ptr = cache->cdata[cbaddr];
170  }
171  ptr++;
172  }
173  } else {
174  do {
175  if (cache->cached & (0x1ULL << cbaddr)) {
176  *ptr = cache->cdata[cbaddr];
177  }
178  ptr++;
179  amount++;
180  cbaddr++;
181  } while (len > amount);
182  }
183  beach:
184  caddr++;
185  cbaddr = 0;
186  }
187  return amount;
188 }
#define RZ_IO_DESC_CACHE_SIZE
Definition: rz_io.h:169
static int
Definition: sfsocketcall.h:114
ut8 cdata[RZ_IO_DESC_CACHE_SIZE]
Definition: rz_io.h:172

References rz_io_desc_cache_t::cached, rz_io_desc_cache_t::cdata, desc, int, len, NULL, RZ_IO_DESC_CACHE_SIZE, rz_io_desc_size(), and ut64().

Referenced by rz_io_desc_read().

◆ rz_io_desc_cache_write()

RZ_API int rz_io_desc_cache_write ( RzIODesc desc,
ut64  paddr,
const ut8 buf,
int  len 
)

Definition at line 86 of file p_cache.c.

86  {
87  RzIODescCache *cache;
88  ut64 caddr, desc_sz = rz_io_desc_size(desc);
89  int cbaddr, written = 0;
90  if ((len < 1) || !desc || (desc_sz <= paddr) ||
91  !desc->io || (!desc->cache && !rz_io_desc_cache_init(desc))) {
92  return 0;
93  }
94  if (len > desc_sz) {
95  len = (int)desc_sz;
96  }
97  if (paddr > (desc_sz - len)) {
98  len = (int)(desc_sz - paddr);
99  }
100  caddr = paddr / RZ_IO_DESC_CACHE_SIZE;
101  cbaddr = paddr % RZ_IO_DESC_CACHE_SIZE;
102  while (written < len) {
103  // get an existing desc-cache, if it exists
104  if (!(cache = (RzIODescCache *)ht_up_find(desc->cache, caddr, NULL))) {
105  // create new desc-cache
106  cache = RZ_NEW0(RzIODescCache);
107  if (!cache) {
108  return 0;
109  }
110  // feed ht with the new desc-cache
111  ht_up_insert(desc->cache, caddr, cache);
112  }
113  // check if the remaining data fits into the cache
114  if ((len - written) > (RZ_IO_DESC_CACHE_SIZE - cbaddr)) {
115  written += (RZ_IO_DESC_CACHE_SIZE - cbaddr);
116  // this can be optimized
117  for (; cbaddr < RZ_IO_DESC_CACHE_SIZE; cbaddr++) {
118  // write to cache
119  cache->cdata[cbaddr] = *buf;
120  // save, that its cached
121  cache->cached |= (0x1ULL << cbaddr);
122  buf++;
123  }
124  } else {
125  // XXX this looks like very suspicious
126  do {
127  cache->cdata[cbaddr] = *buf;
128  cache->cached |= (0x1ULL << cbaddr);
129  buf++;
130  written++;
131  cbaddr++;
132  } while (len > written);
133  }
134  caddr++;
135  cbaddr = 0;
136  }
137  RzEventIOWrite iow = { paddr, buf, len };
138  rz_event_send(desc->io->event, RZ_EVENT_IO_WRITE, &iow);
139  return written;
140 }
RZ_API bool rz_io_desc_cache_init(RzIODesc *desc)
Definition: p_cache.c:79

References rz_io_desc_cache_t::cached, rz_io_desc_cache_t::cdata, desc, int, len, NULL, RZ_EVENT_IO_WRITE, rz_event_send(), rz_io_desc_cache_init(), RZ_IO_DESC_CACHE_SIZE, rz_io_desc_size(), RZ_NEW0, and ut64().

Referenced by rz_io_desc_write().

◆ rz_io_desc_close()

RZ_API bool rz_io_desc_close ( RzIODesc desc)

Definition at line 165 of file io_desc.c.

165  {
166  if (!desc || !desc->io || !desc->plugin) {
167  return false;
168  }
169  RzIO *io = desc->io;
170  RzEventIODescClose ev = { desc };
172  if (desc->plugin->close && desc->plugin->close(desc)) {
173  return false;
174  }
175  // remove entry from idstorage and free the desc-struct
176  rz_io_desc_del(io, desc->fd);
177  // remove all dead maps
178  rz_io_map_cleanup(io);
179  return true;
180 }
RZ_API bool rz_io_desc_del(RzIO *io, int fd)
Definition: io_desc.c:61
@ RZ_EVENT_IO_DESC_CLOSE
Definition: rz_event.h:43
RZ_API void rz_io_map_cleanup(RzIO *io)
Definition: io_map.c:287
Definition: rz_io.h:59

References desc, rz_io_t::event, RZ_EVENT_IO_DESC_CLOSE, rz_event_send(), rz_io_desc_del(), and rz_io_map_cleanup().

Referenced by dmp_close(), handle_tmp_desc(), hash_context_create_desc_io_stdin(), hash_context_create_desc_io_string(), hash_context_run(), io_create_mem_map(), perform_mapped_file_yank(), reopen_in_malloc_cb(), rz_core_cmd_subst_i(), rz_core_file_close(), rz_core_rtr_rap_run(), rz_core_vfile_bin_file_deleted(), rz_diff_io_close(), rz_diff_io_open(), rz_io_close(), rz_io_fd_close(), rz_io_reopen(), and rz_open_binary_file_handler().

◆ rz_io_desc_del()

RZ_API bool rz_io_desc_del ( RzIO io,
int  fd 
)

Definition at line 61 of file io_desc.c.

61  { // can we pass this a riodesc and check if it belongs to the desc->io ?
62  rz_return_val_if_fail(io && io->files, false);
65  if (desc == io->desc) {
66  io->desc = NULL;
67  }
68  // remove all dead maps
70  return true;
71 }
RZ_API void rz_io_desc_free(RzIODesc *desc)
Definition: io_desc.c:35
RZ_API void * rz_id_storage_get(RzIDStorage *storage, ut32 id)
Definition: idpool.c:162
static const z80_opcode fd[]
Definition: z80_tab.h:997

References desc, rz_io_t::desc, fd, rz_io_t::files, NULL, rz_id_storage_get(), rz_io_desc_free(), rz_io_map_cleanup(), and rz_return_val_if_fail.

Referenced by rz_io_desc_close(), and rz_io_reopen().

◆ rz_io_desc_exchange()

RZ_API bool rz_io_desc_exchange ( RzIO io,
int  fd,
int  fdx 
)

Definition at line 275 of file io_desc.c.

275  {
276  RzIODesc *desc, *descx;
277  if (!(desc = rz_io_desc_get(io, fd)) || !(descx = rz_io_desc_get(io, fdx))) {
278  return false;
279  }
280  desc->fd = fdx;
281  descx->fd = fd;
282  rz_id_storage_set(io->files, desc, fdx);
283  rz_id_storage_set(io->files, descx, fd);
284  if (io->p_cache) {
285  HtUP *cache = desc->cache;
286  desc->cache = descx->cache;
287  descx->cache = cache;
290  }
291  void **it;
292  rz_pvector_foreach (&io->maps, it) {
293  RzIOMap *map = *it;
294  if (map->fd == fdx) {
295  map->perm &= (desc->perm | RZ_PERM_X);
296  } else if (map->fd == fd) {
297  map->perm &= (descx->perm | RZ_PERM_X);
298  }
299  }
300  return true;
301 }
size_t map(int syms, int left, int len)
Definition: enough.c:237
RZ_API RzIODesc * rz_io_desc_get(RzIO *io, int fd)
Definition: io_desc.c:73
RZ_API void rz_io_desc_cache_cleanup(RzIODesc *desc)
Definition: p_cache.c:343
#define RZ_PERM_X
Definition: rz_types.h:95
int fd
Definition: rz_io.h:96
int perm
Definition: rz_io.h:97
HtUP * cache
Definition: rz_io.h:101
RzPVector maps
Definition: rz_io.h:73
int p_cache
Definition: rz_io.h:71

References rz_io_desc_t::cache, desc, fd, rz_io_desc_t::fd, rz_io_t::files, map(), rz_io_t::maps, rz_io_t::p_cache, rz_io_desc_t::perm, rz_id_storage_set(), rz_io_desc_cache_cleanup(), rz_io_desc_get(), RZ_PERM_X, and rz_pvector_foreach.

Referenced by reopen_in_malloc_cb(), rz_io_reopen(), and rz_open_exchange_handler().

◆ rz_io_desc_fini()

RZ_IPI bool rz_io_desc_fini ( RzIO io)

Definition at line 390 of file io_desc.c.

390  {
391  rz_return_val_if_fail(io, false);
392  if (io->files) {
395  io->files = NULL;
396  }
397  // no map-cleanup here, to keep it modular useable
398  io->desc = NULL;
399  return true;
400 }
static bool desc_fini_cb(void *user, void *data, ut32 id)
Definition: io_desc.c:380
RZ_API void rz_id_storage_free(RzIDStorage *storage)
Definition: idpool.c:270

References rz_io_t::desc, desc_fini_cb(), rz_io_t::files, NULL, rz_id_storage_foreach(), rz_id_storage_free(), and rz_return_val_if_fail.

Referenced by rz_io_close_all(), rz_io_desc_init(), and rz_io_fini().

◆ rz_io_desc_free()

RZ_API void rz_io_desc_free ( RzIODesc desc)

Definition at line 35 of file io_desc.c.

35  {
36  if (desc) {
37  free(desc->uri);
38  free(desc->referer);
39  free(desc->name);
41  if (desc->io && desc->io->files) {
42  rz_id_storage_delete(desc->io->files, desc->fd);
43  }
44  // free (desc->plugin);
45  }
46  free(desc);
47 }
RZ_API void rz_id_storage_delete(RzIDStorage *storage, ut32 id)
Definition: idpool.c:221
RZ_API void rz_io_desc_cache_fini(RzIODesc *desc)
Definition: p_cache.c:358

References desc, free(), rz_id_storage_delete(), and rz_io_desc_cache_fini().

Referenced by desc_fini_cb(), rz_core_file_open(), rz_core_file_open_many(), rz_io_desc_del(), rz_io_desc_open(), rz_io_desc_open_plugin(), and rz_io_zip_open().

◆ rz_io_desc_get()

RZ_API RzIODesc* rz_io_desc_get ( RzIO io,
int  fd 
)

Definition at line 73 of file io_desc.c.

73  {
74  rz_return_val_if_fail(io && io->files, NULL);
75  return (RzIODesc *)rz_id_storage_get(io->files, fd);
76 }

References fd, rz_io_t::files, NULL, rz_id_storage_get(), and rz_return_val_if_fail.

Referenced by add_map(), basefind_new_bin_file(), core_file_do_load_for_debug(), file_save(), io_map_add(), is_valid_dmp_file(), is_valid_gdb_file(), isValidAddress(), map_multi_dex(), reopen_nobin_headers(), rz_core_bin_apply_maps(), rz_core_bin_load(), rz_core_bin_set_arch_bits(), rz_core_bin_whole_strings(), rz_core_file_binlist(), rz_core_file_close(), rz_core_file_find_by_name(), rz_core_file_info_print(), rz_core_file_open(), rz_core_file_open_load(), rz_core_file_print(), rz_core_file_reopen(), rz_core_file_reopen_debug(), rz_core_file_reopen_remote_debug(), rz_core_raw_file_print(), rz_core_rtr_gdb_cb(), rz_core_setup_debugger(), rz_core_sysenv_begin(), rz_core_visual_title(), rz_io_bind(), rz_io_desc_exchange(), rz_io_desc_get_highest(), rz_io_desc_get_lowest(), rz_io_fd_close(), rz_io_fd_get_base(), rz_io_fd_get_buf(), rz_io_fd_get_name(), rz_io_fd_get_pid(), rz_io_fd_get_tid(), rz_io_fd_is_blockdevice(), rz_io_fd_is_chardevice(), rz_io_fd_is_dbg(), rz_io_fd_read(), rz_io_fd_read_at(), rz_io_fd_resize(), rz_io_fd_seek(), rz_io_fd_size(), rz_io_fd_write(), rz_io_fd_write_at(), rz_io_map_cleanup(), rz_io_reopen(), rz_io_use_fd(), rz_main_rizin(), rz_open_binary_add_handler(), rz_open_malloc_handler(), rz_open_maps_all_fd_handler(), rz_open_maps_map_fd_handler(), rz_open_maps_map_handler(), rz_open_show_current_handler(), rz_write_pcache_commit_handler(), and rz_write_pcache_list_handler().

◆ rz_io_desc_get_base()

RZ_API bool rz_io_desc_get_base ( RzIODesc desc,
ut64 base 
)

Definition at line 344 of file io_desc.c.

344  {
345  if (!base || !desc || !desc->plugin || !desc->plugin->isdbg || !desc->plugin->getbase) {
346  return false;
347  }
348  return desc->plugin->getbase(desc, base);
349 }

References desc.

Referenced by core_file_do_load_for_debug(), rz_debug_get_baddr(), and rz_io_fd_get_base().

◆ rz_io_desc_get_buf()

RZ_API ut8* rz_io_desc_get_buf ( RzIODesc desc,
RZ_OUT RZ_NONNULL ut64 size 
)

Returns the underlying buffer of the io descriptor.

Parameters
[in]descThe io descriptor
[out]sizeSize of buffer returned
Returns
The buffer or NULL if the buffer is not available

Definition at line 241 of file io_desc.c.

241  {
243  if (!desc || !desc->plugin || !desc->plugin->get_buf) {
244  *size = 0;
245  return NULL;
246  }
247  return desc->plugin->get_buf(desc, size);
248 }
voidpf void uLong size
Definition: ioapi.h:138

References desc, NULL, and rz_return_val_if_fail.

Referenced by rz_io_fd_get_buf().

◆ rz_io_desc_get_pid()

RZ_API int rz_io_desc_get_pid ( RzIODesc desc)

Definition at line 310 of file io_desc.c.

310  {
311  //-1 and -2 are reserved
312  if (!desc) {
313  return -3;
314  }
315  if (!desc->plugin) {
316  return -4;
317  }
318  if (!desc->plugin->isdbg) {
319  return -5;
320  }
321  if (!desc->plugin->getpid) {
322  return -6;
323  }
324  return desc->plugin->getpid(desc);
325 }

References desc.

Referenced by rz_core_setup_debugger(), rz_debug_get_baddr(), and rz_io_fd_get_pid().

◆ rz_io_desc_get_tid()

RZ_API int rz_io_desc_get_tid ( RzIODesc desc)

Definition at line 327 of file io_desc.c.

327  {
328  //-1 and -2 are reserved
329  if (!desc) {
330  return -3;
331  }
332  if (!desc->plugin) {
333  return -4;
334  }
335  if (!desc->plugin->isdbg) {
336  return -5;
337  }
338  if (!desc->plugin->gettid) {
339  return -6;
340  }
341  return desc->plugin->gettid(desc);
342 }

References desc.

Referenced by rz_debug_get_baddr(), and rz_io_fd_get_tid().

◆ rz_io_desc_init()

RZ_IPI bool rz_io_desc_init ( RzIO io)

Definition at line 368 of file io_desc.c.

368  {
369  rz_return_val_if_fail(io, false);
370  rz_io_desc_fini(io);
371  // TODO: it leaks if called twice
372  // fd is signed
373  io->files = rz_id_storage_new(3, 0x80000000);
374  if (!io->files) {
375  return false;
376  }
377  return true;
378 }
RZ_IPI bool rz_io_desc_fini(RzIO *io)
Definition: io_desc.c:390
RZ_API RzIDStorage * rz_id_storage_new(ut32 start_id, ut32 last_id)
Definition: idpool.c:80

References rz_io_t::files, rz_id_storage_new(), rz_io_desc_fini(), and rz_return_val_if_fail.

Referenced by rz_io_close_all(), and rz_io_init().

◆ rz_io_desc_is_blockdevice()

RZ_API bool rz_io_desc_is_blockdevice ( RzIODesc desc)

Definition at line 261 of file io_desc.c.

261  {
262  if (!desc || !desc->plugin || !desc->plugin->is_blockdevice) {
263  return false;
264  }
265  return desc->plugin->is_blockdevice(desc);
266 }

References desc.

Referenced by reopen_in_malloc_cb(), and rz_io_fd_is_blockdevice().

◆ rz_io_desc_is_chardevice()

RZ_API bool rz_io_desc_is_chardevice ( RzIODesc desc)

Definition at line 268 of file io_desc.c.

268  {
269  if (!desc || !desc->plugin || !desc->plugin->is_chardevice) {
270  return false;
271  }
272  return desc->plugin->is_chardevice(desc);
273 }

References desc.

Referenced by rz_io_fd_is_chardevice(), rz_io_plugin_read_at(), and rz_io_plugin_write_at().

◆ rz_io_desc_is_dbg()

RZ_API bool rz_io_desc_is_dbg ( RzIODesc desc)

Definition at line 303 of file io_desc.c.

303  {
304  if (desc && desc->plugin) {
305  return desc->plugin->isdbg;
306  }
307  return false;
308 }

References desc.

Referenced by reopen_in_malloc_cb(), rz_core_bin_apply_maps(), rz_core_bin_load(), and rz_io_fd_is_dbg().

◆ rz_io_desc_new()

RZ_API RzIODesc* rz_io_desc_new ( RzIO io,
RzIOPlugin plugin,
const char *  uri,
int  flags,
int  mode,
void *  data 
)

Definition at line 11 of file io_desc.c.

11  {
12  ut32 fd32 = 0;
13  // this is required for emscripten builds to work, but should assert
14  if (!io || !plugin || !uri) {
15  return NULL;
16  }
17  if (io->files) {
18  if (!rz_id_pool_grab_id(io->files->pool, &fd32)) {
19  return NULL;
20  }
21  }
23  if (desc) {
24  desc->fd = fd32;
25  desc->io = io;
26  desc->plugin = plugin;
27  desc->data = data;
28  desc->perm = perm;
29  // because the uri-arg may live on the stack
30  desc->uri = strdup(uri);
31  }
32  return desc;
33 }
uint32_t ut32
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")
RZ_API bool rz_id_pool_grab_id(RzIDPool *pool, ut32 *grabber)
Definition: idpool.c:34
RzIDPool * pool
Definition: rz_idpool.h:28

References desc, rz_io_t::files, NULL, rz_id_storage_t::pool, rz_id_pool_grab_id(), RZ_NEW0, and strdup().

Referenced by __open(), __rap_open(), dmp_open(), find_apk_binary(), rz_io_ar_open(), rz_io_ar_open_many(), rz_io_def_mmap_open(), rz_io_zip_open(), rz_io_zip_open_many(), rzk__open(), vf_open(), and windbg_open().

◆ rz_io_desc_open()

RZ_API RzIODesc* rz_io_desc_open ( RzIO io,
const char *  uri,
int  flags,
int  mode 
)

Definition at line 112 of file io_desc.c.

112  {
113  rz_return_val_if_fail(io && uri, NULL);
114  RzIOPlugin *plugin = rz_io_plugin_resolve(io, uri, 0);
115  if (!plugin || !plugin->open) {
116  return NULL;
117  }
118  RzIODesc *desc = plugin->open(io, uri, perm, mode);
119  if (!desc) {
120  return NULL;
121  }
122  // for none static callbacks, those that cannot use rz_io_desc_new
123  if (!desc->name) {
124  desc->name = strdup(uri);
125  }
126  if (!desc->uri) {
127  desc->uri = strdup(uri);
128  }
129  if (!desc->plugin) {
130  desc->plugin = plugin;
131  }
132  if (!rz_io_desc_add(io, desc)) {
134  return NULL;
135  }
136  return desc;
137 }
RZ_API bool rz_io_desc_add(RzIO *io, RzIODesc *desc)
Definition: io_desc.c:49
const char int mode
Definition: ioapi.h:137
RZ_API RzIOPlugin * rz_io_plugin_resolve(RzIO *io, const char *filename, bool many)
Definition: io_plugin.c:54
RzIODesc *(* open)(RzIO *io, const char *, int perm, int mode)
Definition: rz_io.h:127

References desc, NULL, rz_io_plugin_t::open, rz_io_desc_add(), rz_io_desc_free(), rz_io_plugin_resolve(), rz_return_val_if_fail, and strdup().

Referenced by rz_io_fd_open(), and rz_io_open_nomap().

◆ rz_io_desc_open_plugin()

RZ_API RzIODesc* rz_io_desc_open_plugin ( RzIO io,
RzIOPlugin plugin,
const char *  uri,
int  flags,
int  mode 
)

Definition at line 139 of file io_desc.c.

139  {
140  rz_return_val_if_fail(io && io->files && uri, NULL);
141  if (!plugin || !plugin->open || !plugin->check || !plugin->check(io, uri, false)) {
142  return NULL;
143  }
144  RzIODesc *desc = plugin->open(io, uri, perm, mode);
145  if (!desc) {
146  return NULL;
147  }
148  // for none static callbacks, those that cannot use rz_io_desc_new
149  if (!desc->plugin) {
150  desc->plugin = plugin;
151  }
152  if (!desc->uri) {
153  desc->uri = strdup(uri);
154  }
155  if (!desc->name) {
156  desc->name = strdup(uri);
157  }
158  if (!rz_io_desc_add(io, desc)) {
160  return NULL;
161  }
162  return desc;
163 }
bool(* check)(RzIO *io, const char *, bool many)
Definition: rz_io.h:141

References rz_io_plugin_t::check, desc, rz_io_t::files, NULL, rz_io_plugin_t::open, rz_io_desc_add(), rz_io_desc_free(), rz_return_val_if_fail, and strdup().

◆ rz_io_desc_read()

RZ_API int rz_io_desc_read ( RzIODesc desc,
ut8 buf,
int  count 
)

Definition at line 197 of file io_desc.c.

197  {
198  // check pointers and permissions
199  if (!buf || !desc || !desc->plugin || !(desc->perm & RZ_PERM_R)) {
200  return -1;
201  }
203  if (desc->io->cachemode) {
204  if (seek != UT64_MAX && rz_io_cache_at(desc->io, seek)) {
205  return rz_io_cache_read(desc->io, seek, buf, len);
206  }
207  }
208  int ret = rz_io_plugin_read(desc, buf, len);
209  if (ret > 0 && desc->io->cachemode) {
211  } else if ((ret > 0) && desc->io && (desc->io->p_cache & 1)) {
212  ret = rz_io_desc_cache_read(desc, seek, buf, ret);
213  }
214  return ret;
215 }
RZ_API ut64 rz_io_desc_seek(RzIODesc *desc, ut64 offset, int whence)
Definition: io_desc.c:217
RZ_API bool rz_io_cache_at(RzIO *io, ut64 addr)
Definition: io_cache.c:16
RZ_API bool rz_io_cache_read(RzIO *io, ut64 addr, ut8 *buf, int len)
Definition: io_cache.c:131
#define RZ_IO_SEEK_CUR
Definition: rz_io.h:16
RZ_API bool rz_io_cache_write(RzIO *io, ut64 addr, const ut8 *buf, int len)
Definition: io_cache.c:93
RZ_API int rz_io_desc_cache_read(RzIODesc *desc, ut64 paddr, ut8 *buf, int len)
Definition: p_cache.c:142
RZ_API int rz_io_plugin_read(RzIODesc *desc, ut8 *buf, int len)
Definition: io_plugin.c:79
#define RZ_PERM_R
Definition: rz_types.h:93
static int seek(char *argv[])

References desc, len, rz_io_cache_at(), rz_io_cache_read(), rz_io_cache_write(), rz_io_desc_cache_read(), rz_io_desc_seek(), rz_io_plugin_read(), RZ_IO_SEEK_CUR, RZ_PERM_R, seek(), ut64(), and UT64_MAX.

Referenced by rz_io_desc_read_at(), and rz_io_fd_read().

◆ rz_io_desc_read_at()

RZ_API int rz_io_desc_read_at ( RzIODesc desc,
ut64  addr,
ut8 buf,
int  len 
)

Definition at line 351 of file io_desc.c.

351  {
352  if (desc && buf && (rz_io_desc_seek(desc, addr, RZ_IO_SEEK_SET) == addr)) {
353  return rz_io_desc_read(desc, buf, len);
354  }
355  return 0;
356 }
RZ_API int rz_io_desc_read(RzIODesc *desc, ut8 *buf, int len)
Definition: io_desc.c:197
#define RZ_IO_SEEK_SET
Definition: rz_io.h:15

References addr, desc, len, rz_io_desc_read(), rz_io_desc_seek(), and RZ_IO_SEEK_SET.

Referenced by dmp_read(), read_at_kernel_virtual(), reopen_in_malloc_cb(), rz_io_fd_read_at(), and rz_io_pread_at().

◆ rz_io_desc_resize()

RZ_API bool rz_io_desc_resize ( RzIODesc desc,
ut64  newsize 
)

Definition at line 250 of file io_desc.c.

250  {
251  if (desc && desc->plugin && desc->plugin->resize) {
252  bool ret = desc->plugin->resize(desc->io, desc, newsize);
253  if (desc->io && desc->io->p_cache) {
255  }
256  return ret;
257  }
258  return false;
259 }

References desc, and rz_io_desc_cache_cleanup().

Referenced by rz_io_fd_resize(), and rz_io_resize().

◆ rz_io_desc_seek()

RZ_API ut64 rz_io_desc_seek ( RzIODesc desc,
ut64  offset,
int  whence 
)

Definition at line 217 of file io_desc.c.

217  {
218  if (!desc || !desc->plugin || !desc->plugin->lseek) {
219  return (ut64)-1;
220  }
221  return desc->plugin->lseek(desc->io, desc, offset, whence);
222 }
voidpf uLong offset
Definition: ioapi.h:144

References desc, and ut64().

Referenced by dmp_lseek(), rz_io_desc_read(), rz_io_desc_read_at(), rz_io_desc_size(), rz_io_desc_write(), rz_io_desc_write_at(), rz_io_fd_seek(), rz_io_plugin_read_at(), rz_io_plugin_write(), rz_io_plugin_write_at(), rz_io_seek(), and rz_io_shift().

◆ rz_io_desc_size()

◆ rz_io_desc_write()

RZ_API int rz_io_desc_write ( RzIODesc desc,
const ut8 buf,
int  count 
)

Definition at line 183 of file io_desc.c.

183  {
185  if (len < 0) {
186  return -1;
187  }
188  // check pointers and pcache
189  if (desc->io && (desc->io->p_cache & 2)) {
192  }
193  return rz_io_plugin_write(desc, buf, len);
194 }
RZ_API int rz_io_plugin_write(RzIODesc *desc, const ut8 *buf, int len)
Definition: io_plugin.c:89
RZ_API int rz_io_desc_cache_write(RzIODesc *desc, ut64 paddr, const ut8 *buf, int len)
Definition: p_cache.c:86

References desc, len, rz_io_desc_cache_write(), rz_io_desc_seek(), rz_io_plugin_write(), RZ_IO_SEEK_CUR, and rz_return_val_if_fail.

Referenced by rz_io_desc_write_at(), rz_io_fd_write(), and rz_io_open_buffer().

◆ rz_io_desc_write_at()

RZ_API int rz_io_desc_write_at ( RzIODesc desc,
ut64  addr,
const ut8 buf,
int  len 
)

Definition at line 358 of file io_desc.c.

358  {
359  if (desc && buf && (rz_io_desc_seek(desc, addr, RZ_IO_SEEK_SET) == addr)) {
360  return rz_io_desc_write(desc, buf, len);
361  }
362  return 0;
363 }
RZ_API int rz_io_desc_write(RzIODesc *desc, const ut8 *buf, int len)
Definition: io_desc.c:183

References addr, desc, len, rz_io_desc_seek(), rz_io_desc_write(), and RZ_IO_SEEK_SET.

Referenced by dmp_write(), reopen_in_malloc_cb(), rz_io_fd_write_at(), rz_io_pwrite_at(), and rz_open_malloc_handler().

◆ rz_io_extend_at()

RZ_API bool rz_io_extend_at ( RzIO io,
ut64  addr,
ut64  size 
)

Extend the RzIODesc at addr by inserting size 0 bytes.

Parameters
ioReference to RzIO instance
addrAddress where to insert new 0 bytes
sizeNumber of 0 bytes to insert
Returns
true if extend operation was successful, false otherwise

Definition at line 453 of file io.c.

453  {
454 #define IO_EXTEND_BLOCK_SZ 256
455  rz_return_val_if_fail(io, false);
456 
457  if (!io->desc || !io->desc->plugin) {
458  return false;
459  }
460  if (size == 0) {
461  return true;
462  }
463 
464  if ((io->desc->perm & RZ_PERM_RW) != RZ_PERM_RW) {
465  return false;
466  }
467  ut64 cur_size = rz_io_desc_size(io->desc);
468  if (addr > cur_size) {
469  return false;
470  }
471 
472  // Extend the file to include the additional <size> bytes
473  if (UT64_ADD_OVFCHK(cur_size, size)) {
474  return false;
475  }
476  if (!rz_io_resize(io, cur_size + size)) {
477  return false;
478  }
479 
480  // Shift old data to make space for the zero bytes
481  ut64 tmp = cur_size >= IO_EXTEND_BLOCK_SZ ? RZ_MAX(cur_size - IO_EXTEND_BLOCK_SZ, addr) : addr;
482  ut64 remaining = cur_size - addr;
483 
485  if (!buffer) {
486  return false;
487  }
488  while (remaining) {
490  rz_io_pwrite_at(io, tmp + size, buffer, sz);
491 
493  remaining = remaining > sz ? remaining - sz : 0;
494  }
495  free(buffer);
496 
497  // Put the zero bytes at the right place
498  ut8 *empty = RZ_NEWS0(ut8, size);
499  if (!empty) {
500  return false;
501  }
502  rz_io_pwrite_at(io, addr, empty, size);
503  free(empty);
504 
505  return true;
506 #undef IO_EXTEND_BLOCK_SZ
507 }
RZ_API int rz_io_pwrite_at(RzIO *io, ut64 paddr, const ut8 *buf, int len)
Definition: io.c:277
#define IO_EXTEND_BLOCK_SZ
RZ_API bool rz_io_resize(RzIO *io, ut64 newsize)
Definition: io.c:418
RZ_API int rz_io_pread_at(RzIO *io, ut64 paddr, ut8 *buf, int len)
Definition: io.c:269
#define RZ_NEWS(x, y)
Definition: rz_types.h:283
#define RZ_PERM_RW
Definition: rz_types.h:96
#define RZ_NEWS0(x, y)
Definition: rz_types.h:282
#define RZ_MAX(x, y)
Definition: buffer.h:15
struct rz_io_plugin_t * plugin
Definition: rz_io.h:103

References addr, rz_io_t::desc, free(), IO_EXTEND_BLOCK_SZ, rz_io_desc_t::perm, rz_io_desc_t::plugin, rz_io_desc_size(), rz_io_pread_at(), rz_io_pwrite_at(), rz_io_resize(), RZ_MAX, RZ_NEWS, RZ_NEWS0, RZ_PERM_RW, rz_return_val_if_fail, autogen_x86imm::tmp, ut64(), and UT64_ADD_OVFCHK.

Referenced by rz_core_extend_at().

◆ rz_io_fd_close()

◆ rz_io_fd_get_base()

RZ_API bool rz_io_fd_get_base ( RzIO io,
int  fd,
ut64 base 
)

Definition at line 106 of file io_fd.c.

106  {
107  rz_return_val_if_fail(io && io->files && base, false);
108  RzIODesc *desc = rz_io_desc_get(io, fd);
109  return rz_io_desc_get_base(desc, base);
110 }
RZ_API bool rz_io_desc_get_base(RzIODesc *desc, ut64 *base)
Definition: io_desc.c:344

References desc, fd, rz_io_t::files, rz_io_desc_get(), rz_io_desc_get_base(), and rz_return_val_if_fail.

◆ rz_io_fd_get_buf()

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.

Parameters
[in]ioThe RzIO instance
[in]fdThe file descriptor
[out]sizeSize of the buffer returned
Returns
The buffer or NULL if the file descriptor is invalid or the buffer is not available

Definition at line 53 of file io_fd.c.

53  {
56 }
RZ_API ut8 * rz_io_desc_get_buf(RzIODesc *desc, RZ_OUT RZ_NONNULL ut64 *size)
Returns the underlying buffer of the io descriptor.
Definition: io_desc.c:241

References fd, NULL, rz_io_desc_get(), rz_io_desc_get_buf(), and rz_return_val_if_fail.

Referenced by rz_io_bind().

◆ rz_io_fd_get_current()

◆ rz_io_fd_get_highest()

RZ_API int rz_io_fd_get_highest ( RzIO io)

Definition at line 161 of file io_fd.c.

161  {
162  rz_return_val_if_fail(io, -1);
163  int fd = -1;
164  if (!rz_id_storage_get_highest(io->files, (ut32 *)&fd)) {
165  return -1;
166  }
167  return fd;
168 }
RZ_API bool rz_id_storage_get_highest(RzIDStorage *storage, ut32 *id)
Definition: idpool.c:178

References fd, rz_io_t::files, rz_id_storage_get_highest(), and rz_return_val_if_fail.

Referenced by rz_io_desc_get_highest().

◆ rz_io_fd_get_lowest()

RZ_API int rz_io_fd_get_lowest ( RzIO io)

Definition at line 170 of file io_fd.c.

170  {
171  rz_return_val_if_fail(io, -1);
172  int fd = -1;
173  if (!rz_id_storage_get_lowest(io->files, (ut32 *)&fd)) {
174  return -1;
175  }
176  return fd;
177 }
RZ_API bool rz_id_storage_get_lowest(RzIDStorage *storage, ut32 *id)
Definition: idpool.c:169

References fd, rz_io_t::files, rz_id_storage_get_lowest(), and rz_return_val_if_fail.

Referenced by rz_io_desc_get_lowest(), and rz_open_prioritize_next_rotate_handler().

◆ rz_io_fd_get_name()

RZ_API const char* rz_io_fd_get_name ( RzIO io,
int  fd 
)

Definition at line 112 of file io_fd.c.

112  {
113  rz_return_val_if_fail(io && io->files, NULL);
114  RzIODesc *desc = rz_io_desc_get(io, fd);
115  return desc ? desc->name : NULL;
116 }

References desc, fd, rz_io_t::files, NULL, rz_io_desc_get(), and rz_return_val_if_fail.

Referenced by rz_io_bind().

◆ rz_io_fd_get_next()

RZ_API int rz_io_fd_get_next ( RzIO io,
int  fd 
)

Definition at line 143 of file io_fd.c.

143  {
144  rz_return_val_if_fail(io, -1);
145  int ret = fd;
146  if (!rz_id_storage_get_next(io->files, (ut32 *)&ret)) {
147  return -1;
148  }
149  return ret;
150 }
RZ_API bool rz_id_storage_get_next(RzIDStorage *storage, ut32 *id)
Definition: idpool.c:191

References fd, rz_io_t::files, rz_id_storage_get_next(), and rz_return_val_if_fail.

Referenced by rz_io_desc_get_next(), rz_open_prioritize_next_handler(), and rz_open_prioritize_next_rotate_handler().

◆ rz_io_fd_get_pid()

RZ_API int rz_io_fd_get_pid ( RzIO io,
int  fd 
)

Definition at line 92 of file io_fd.c.

92  {
93  if (!io || !io->files) {
94  return -2;
95  }
97  return rz_io_desc_get_pid(desc);
98 }
RZ_API int rz_io_desc_get_pid(RzIODesc *desc)
Definition: io_desc.c:310

References desc, fd, rz_io_t::files, rz_io_desc_get(), and rz_io_desc_get_pid().

Referenced by cb_cfgdebug(), cmd_debug_pid(), core_file_do_load_for_debug(), rz_core_debug_attach(), and rz_core_file_reopen().

◆ rz_io_fd_get_prev()

RZ_API int rz_io_fd_get_prev ( RzIO io,
int  fd 
)

Definition at line 152 of file io_fd.c.

152  {
153  rz_return_val_if_fail(io, -1);
154  int ret = fd;
155  if (!rz_id_storage_get_prev(io->files, (ut32 *)&ret)) {
156  return -1;
157  }
158  return ret;
159 }
RZ_API bool rz_id_storage_get_prev(RzIDStorage *storage, ut32 *id)
Definition: idpool.c:206

References fd, rz_io_t::files, rz_id_storage_get_prev(), and rz_return_val_if_fail.

Referenced by rz_io_desc_get_prev(), and rz_open_prioritize_prev_handler().

◆ rz_io_fd_get_tid()

RZ_API int rz_io_fd_get_tid ( RzIO io,
int  fd 
)

Definition at line 100 of file io_fd.c.

100  {
101  rz_return_val_if_fail(io && io->files, -2);
102  RzIODesc *desc = rz_io_desc_get(io, fd);
103  return rz_io_desc_get_tid(desc);
104 }
RZ_API int rz_io_desc_get_tid(RzIODesc *desc)
Definition: io_desc.c:327

References desc, fd, rz_io_t::files, rz_io_desc_get(), rz_io_desc_get_tid(), and rz_return_val_if_fail.

Referenced by cb_cfgdebug(), cmd_debug_pid(), core_file_do_load_for_debug(), and rz_core_file_reopen().

◆ rz_io_fd_is_blockdevice()

RZ_API bool rz_io_fd_is_blockdevice ( RzIO io,
int  fd 
)

Definition at line 62 of file io_fd.c.

62  {
64 }
RZ_API bool rz_io_desc_is_blockdevice(RzIODesc *desc)
Definition: io_desc.c:261

References fd, rz_io_desc_get(), and rz_io_desc_is_blockdevice().

◆ rz_io_fd_is_chardevice()

RZ_API bool rz_io_fd_is_chardevice ( RzIO io,
int  fd 
)

Definition at line 66 of file io_fd.c.

66  {
68 }
RZ_API bool rz_io_desc_is_chardevice(RzIODesc *desc)
Definition: io_desc.c:268

References fd, rz_io_desc_get(), and rz_io_desc_is_chardevice().

◆ rz_io_fd_is_dbg()

RZ_API bool rz_io_fd_is_dbg ( RzIO io,
int  fd 
)

Definition at line 86 of file io_fd.c.

86  {
87  rz_return_val_if_fail(io && io->files, false);
89  return desc ? rz_io_desc_is_dbg(desc) : false;
90 }
RZ_API bool rz_io_desc_is_dbg(RzIODesc *desc)
Definition: io_desc.c:303

References desc, fd, rz_io_t::files, rz_io_desc_get(), rz_io_desc_is_dbg(), and rz_return_val_if_fail.

Referenced by rz_io_bind().

◆ rz_io_fd_open()

RZ_API int rz_io_fd_open ( RzIO io,
const char *  uri,
int  flags,
int  mode 
)

Definition at line 6 of file io_fd.c.

6  {
7  RzIODesc *desc = rz_io_desc_open(io, uri, flags, mode);
8  return desc ? desc->fd : -1;
9 }
RZ_API RzIODesc * rz_io_desc_open(RzIO *io, const char *uri, int flags, int mode)
Definition: io_desc.c:112
static struct sockaddr static addrlen static backlog const void static flags void flags
Definition: sfsocketcall.h:123

References desc, flags, and rz_io_desc_open().

Referenced by ds_init(), get_bin_info(), GetHeapGlobalsOffset(), rz_core_analysis_esil_init_mem(), and rz_io_bind().

◆ rz_io_fd_read()

RZ_API int rz_io_fd_read ( RzIO io,
int  fd,
ut8 buf,
int  len 
)

Definition at line 16 of file io_fd.c.

16  {
17  rz_return_val_if_fail(io && buf, -1);
18  if (len < 0) {
19  return -1;
20  }
22  return desc ? rz_io_desc_read(desc, buf, len) : -1;
23 }
RZ_API int rz_io_desc_read(RzIODesc *desc, ut8 *buf, int count)
Definition: io_desc.c:197

References desc, fd, len, rz_io_desc_get(), rz_io_desc_read(), and rz_return_val_if_fail.

Referenced by rz_io_bind().

◆ rz_io_fd_read_at()

RZ_API int rz_io_fd_read_at ( RzIO io,
int  fd,
ut64  addr,
ut8 buf,
int  len 
)

Definition at line 71 of file io_fd.c.

71  {
72  RzIODesc *desc;
73  if (!io || !buf || (len < 1) || !(desc = rz_io_desc_get(io, fd))) {
74  return 0;
75  }
76  return rz_io_desc_read_at(desc, addr, buf, len);
77 }
RZ_API int rz_io_desc_read_at(RzIODesc *desc, ut64 addr, ut8 *buf, int len)
Definition: io_desc.c:351

References addr, desc, fd, len, rz_io_desc_get(), and rz_io_desc_read_at().

Referenced by fd_read_at_wrap(), and rz_io_bind().

◆ rz_io_fd_resize()

RZ_API bool rz_io_fd_resize ( RzIO io,
int  fd,
ut64  newsize 
)

Definition at line 58 of file io_fd.c.

58  {
59  return rz_io_desc_resize(rz_io_desc_get(io, fd), newsize);
60 }
RZ_API bool rz_io_desc_resize(RzIODesc *desc, ut64 newsize)
Definition: io_desc.c:250

References fd, rz_io_desc_get(), and rz_io_desc_resize().

Referenced by rz_io_bind().

◆ rz_io_fd_seek()

RZ_API ut64 rz_io_fd_seek ( RzIO io,
int  fd,
ut64  addr,
int  whence 
)

Definition at line 35 of file io_fd.c.

35  {
36  if (!io) {
37  return (ut64)-2;
38  }
39  return rz_io_desc_seek(rz_io_desc_get(io, fd), addr, whence);
40 }
RZ_API ut64 rz_io_desc_seek(RzIODesc *desc, ut64 offset, int whence)
Definition: io_desc.c:217

References addr, fd, rz_io_desc_get(), rz_io_desc_seek(), and ut64().

Referenced by rz_io_bind().

◆ rz_io_fd_size()

◆ rz_io_fd_write()

RZ_API int rz_io_fd_write ( RzIO io,
int  fd,
const ut8 buf,
int  len 
)

Definition at line 26 of file io_fd.c.

26  {
27  rz_return_val_if_fail(io && buf, -1);
28  if (len < 0) {
29  return -1;
30  }
32  return desc ? rz_io_desc_write(desc, buf, len) : -1;
33 }
RZ_API int rz_io_desc_write(RzIODesc *desc, const ut8 *buf, int count)
Definition: io_desc.c:183

References desc, fd, len, rz_io_desc_get(), rz_io_desc_write(), and rz_return_val_if_fail.

Referenced by rz_io_bind().

◆ rz_io_fd_write_at()

RZ_API int rz_io_fd_write_at ( RzIO io,
int  fd,
ut64  addr,
const ut8 buf,
int  len 
)

Definition at line 80 of file io_fd.c.

80  {
81  rz_return_val_if_fail(io && buf, false);
83  return desc ? rz_io_desc_write_at(desc, addr, buf, len) : -1;
84 }
RZ_API int rz_io_desc_write_at(RzIODesc *desc, ut64 addr, const ut8 *buf, int len)
Definition: io_desc.c:358

References addr, desc, fd, len, rz_io_desc_get(), rz_io_desc_write_at(), and rz_return_val_if_fail.

Referenced by fd_write_at_wrap(), and rz_io_bind().

◆ rz_io_fini()

RZ_API int rz_io_fini ( RzIO io)

Definition at line 724 of file io.c.

724  {
725  if (!io) {
726  return false;
727  }
729  rz_io_desc_fini(io);
730  rz_io_map_fini(io);
731  rz_list_free(io->plugins);
732  rz_io_cache_fini(io);
733  if (io->runprofile) {
734  RZ_FREE(io->runprofile);
735  }
736  rz_event_free(io->event);
737  free(io->envprofile);
738 #if RZ_IO_USE_PTRACE_WRAP
739  if (io->ptrace_wrap) {
740  ptrace_wrap_instance_stop(io->ptrace_wrap);
741  free(io->ptrace_wrap);
742  }
743 #endif
744 #if __WINDOWS__
745  w32dbg_wrap_free((W32DbgWInst *)io->priv_w32dbg_wrap);
746 #endif
747  return true;
748 }
void ptrace_wrap_instance_stop(ptrace_wrap_instance *inst)
Definition: ptrace_wrap.c:36
RZ_API void rz_event_free(RzEvent *ev)
Definition: event.c:37
RZ_API void rz_io_desc_cache_fini_all(RzIO *io)
Definition: p_cache.c:362
RZ_API void rz_io_map_fini(RzIO *io)
Definition: io_map.c:318
#define RZ_FREE(x)
Definition: rz_types.h:369
char * runprofile
Definition: rz_io.h:81
char * envprofile
Definition: rz_io.h:82
RzList * plugins
Definition: rz_io.h:80
void w32dbg_wrap_free(W32DbgWInst *inst)
Definition: w32dbg_wrap.c:58

References rz_io_t::envprofile, rz_io_t::event, free(), rz_io_t::plugins, ptrace_wrap_instance_stop(), rz_io_t::runprofile, rz_event_free(), RZ_FREE, rz_io_cache_fini(), rz_io_desc_cache_fini_all(), rz_io_desc_fini(), rz_io_map_fini(), rz_list_free(), and w32dbg_wrap_free().

Referenced by rz_io_free().

◆ rz_io_free()

RZ_API void rz_io_free ( RzIO io)

Definition at line 126 of file io.c.

126  {
127  if (io) {
128  rz_io_fini(io);
129  free(io);
130  }
131 }
RZ_API int rz_io_fini(RzIO *io)
Definition: io.c:724

References free(), and rz_io_fini().

Referenced by download_pdb(), hash_context_run(), rz_core_fini(), rz_diff_io_close(), rz_diff_io_open(), and rzfind_open_file().

◆ rz_io_init()

RZ_API RzIO* rz_io_init ( RzIO io)

Definition at line 114 of file io.c.

114  {
116  io->addrbytes = 1;
117  rz_io_desc_init(io);
119  rz_io_map_init(io);
120  rz_io_cache_init(io);
121  rz_io_plugin_init(io);
122  io->event = rz_event_new(io);
123  return io;
124 }
RZ_API RzEvent * rz_event_new(void *user)
Definition: event.c:17
RZ_API bool rz_io_plugin_init(RzIO *io)
Definition: io_plugin.c:32
RZ_API void rz_io_cache_init(RzIO *io)
Definition: io_cache.c:21
RZ_API void rz_io_map_init(RzIO *io)
Definition: io_map.c:101
size_t addrbytes
Definition: rz_io.h:66
RzSkyline map_skyline
Definition: rz_io.h:74

References rz_io_t::addrbytes, rz_io_t::event, rz_io_t::map_skyline, NULL, rz_event_new(), rz_io_cache_init(), rz_io_desc_init(), rz_io_map_init(), rz_io_plugin_init(), rz_return_val_if_fail, and rz_skyline_init().

Referenced by rz_io_new().

◆ rz_io_is_listener()

RZ_API bool rz_io_is_listener ( RzIO io)

Definition at line 404 of file io.c.

404  {
405  if (io && io->desc && io->desc->plugin && io->desc->plugin->listener) {
406  return io->desc->plugin->listener(io->desc);
407  }
408  return false;
409 }
int(* listener)(RzIODesc *io)
Definition: rz_io.h:122

References rz_io_t::desc, rz_io_plugin_t::listener, and rz_io_desc_t::plugin.

Referenced by rz_core_file_open(), and rz_core_rtr_rap_run().

◆ rz_io_is_valid_offset()

RZ_API bool rz_io_is_valid_offset ( RzIO io,
ut64  offset,
int  hasperm 
)

Definition at line 20 of file ioutils.c.

20  {
21  rz_return_val_if_fail(io, false);
22  if (io->va) {
23  if (!hasperm) {
24  // return rz_io_map_is_mapped (io, offset);
26  return map ? map->perm & RZ_PERM_R : false;
27  }
29  return map ? (map->perm & hasperm) == hasperm : false;
30  }
31  if (!io->desc) {
32  return false;
33  }
34  if (offset > rz_io_desc_size(io->desc)) {
35  return false;
36  }
37  return ((io->desc->perm & hasperm) == hasperm);
38 }

References rz_io_t::desc, map(), rz_io_desc_t::perm, rz_io_desc_size(), rz_io_map_get(), RZ_PERM_R, rz_return_val_if_fail, and rz_io_t::va.

Referenced by __core_analysis_fcn(), __op_refs(), _analysis_calls(), _pointer_table(), agraph_refresh(), do_string_search(), ds_print_core_vmode(), esilbreak_reg_write(), is_valid_xref(), mymemread(), mymemwrite(), myregwrite(), myvalid(), rz_analyze_all_data_references_to_code_handler(), rz_core_analysis_esil(), rz_core_analysis_fcn(), rz_core_analysis_function_add(), rz_core_analysis_search_xrefs(), rz_core_asm_strsearch(), rz_core_esil_step(), rz_core_is_valid_offset(), rz_core_search_prelude(), rz_core_search_value_in_range(), and rz_io_bind().

◆ rz_io_map_add()

RZ_API RzIOMap* rz_io_map_add ( RzIO io,
int  fd,
int  flags,
ut64  delta,
ut64  addr,
ut64  size 
)

Definition at line 151 of file io_map.c.

151  {
152  return io_map_add(io, fd, perm, delta, addr, size);
153 }
RzIOMap * io_map_add(RzIO *io, int fd, int perm, ut64 delta, ut64 addr, ut64 size)
Definition: io_map.c:140
static st64 delta
Definition: vmenus.c:2425

References addr, delta, fd, and io_map_add().

Referenced by ds_init(), rz_core_analysis_esil_init_mem(), rz_core_serve(), rz_io_bind(), rz_open_maps_all_fd_handler(), rz_open_maps_map_fd_handler(), and rz_open_maps_map_handler().

◆ rz_io_map_add_batch()

RZ_API RzIOMap* rz_io_map_add_batch ( RzIO io,
int  fd,
int  flags,
ut64  delta,
ut64  addr,
ut64  size 
)

Definition at line 155 of file io_map.c.

155  {
156  return io_map_add(io, fd, perm, delta, addr, size);
157 }

References addr, delta, fd, and io_map_add().

Referenced by add_map(), and io_create_mem_map().

◆ rz_io_map_cleanup()

RZ_API void rz_io_map_cleanup ( RzIO io)

Definition at line 287 of file io_map.c.

287  {
288  rz_return_if_fail(io);
289  // remove all maps if no descs exist
290  if (!io->files) {
291  rz_io_map_fini(io);
292  rz_io_map_init(io);
293  return;
294  }
295  bool del = false;
296  size_t i;
297  for (i = 0; i < rz_pvector_len(&io->maps);) {
298  RzIOMap *map = rz_pvector_at(&io->maps, i);
299  if (!map) {
300  // remove iter if the map is a null-ptr, this may fix some segfaults. This should never happen.
302  rz_pvector_remove_at(&io->maps, i);
303  del = true;
304  } else if (!rz_io_desc_get(io, map->fd)) {
305  // delete map and iter if no desc exists for map->fd in io->files
306  map = rz_pvector_remove_at(&io->maps, i);
307  map_del(io, map);
308  del = true;
309  } else {
310  i++;
311  }
312  }
313  if (del) {
315  }
316 }
lzma_index ** i
Definition: index.h:629
void io_map_calculate_skyline(RzIO *io)
Definition: io_map.c:14
RZ_API void rz_io_map_init(RzIO *io)
Definition: io_map.c:101
static void map_del(RzIO *io, RzIOMap *map)
Free the map, also sending the appropriate event.
Definition: io_map.c:93
RZ_API void rz_io_map_fini(RzIO *io)
Definition: io_map.c:318
static void del(RzAnalysis *a, RzAnalysisMetaType type, const RzSpace *space, ut64 addr, ut64 size)
Definition: meta.c:155
#define rz_warn_if_reached()
Definition: rz_assert.h:29
static size_t rz_pvector_len(const RzPVector *vec)
Definition: rz_vector.h:231
RZ_API void * rz_pvector_remove_at(RzPVector *vec, size_t index)
Definition: vector.c:355
static void * rz_pvector_at(const RzPVector *vec, size_t index)
Definition: rz_vector.h:236

References del(), rz_io_t::files, i, io_map_calculate_skyline(), map(), map_del(), rz_io_t::maps, rz_io_desc_get(), rz_io_map_fini(), rz_io_map_init(), rz_pvector_at(), rz_pvector_len(), rz_pvector_remove_at(), rz_return_if_fail, and rz_warn_if_reached.

Referenced by rz_io_desc_close(), rz_io_desc_del(), and rz_io_map_priorize_for_fd().

◆ rz_io_map_del()

RZ_API bool rz_io_map_del ( RzIO io,
ut32  id 
)

Definition at line 192 of file io_map.c.

192  {
193  rz_return_val_if_fail(io, false);
194  size_t i;
195  for (i = 0; i < rz_pvector_len(&io->maps); i++) {
196  RzIOMap *map = rz_pvector_at(&io->maps, i);
197  if (map->id == id) {
198  rz_pvector_remove_at(&io->maps, i);
199  map_del(io, map);
201  return true;
202  }
203  }
204  return false;
205 }

References i, io_map_calculate_skyline(), map(), map_del(), rz_io_t::maps, rz_pvector_at(), rz_pvector_len(), rz_pvector_remove_at(), and rz_return_val_if_fail.

Referenced by rz_core_file_close(), rz_debug_dmp_init(), and rz_open_maps_remove_handler().

◆ rz_io_map_del_for_fd()

RZ_API bool rz_io_map_del_for_fd ( RzIO io,
int  fd 
)

Definition at line 208 of file io_map.c.

208  {
209  rz_return_val_if_fail(io, false);
210  bool ret = false;
211  size_t i;
212  for (i = 0; i < rz_pvector_len(&io->maps);) {
213  RzIOMap *map = rz_pvector_at(&io->maps, i);
214  if (!map) {
215  rz_pvector_remove_at(&io->maps, i);
216  } else if (map->fd == fd) {
217  rz_pvector_remove_at(&io->maps, i);
218  map_del(io, map);
219  ret = true;
220  } else {
221  i++;
222  }
223  }
224  if (ret) {
226  }
227  return ret;
228 }

References fd, i, io_map_calculate_skyline(), map(), map_del(), rz_io_t::maps, rz_pvector_at(), rz_pvector_len(), rz_pvector_remove_at(), and rz_return_val_if_fail.

◆ rz_io_map_del_name()

RZ_API void rz_io_map_del_name ( RzIOMap map)

Definition at line 340 of file io_map.c.

340  {
341  if (map) {
342  RZ_FREE(map->name);
343  }
344 }

References map(), and RZ_FREE.

Referenced by rz_open_maps_name_del_handler(), and rz_open_maps_name_id_del_handler().

◆ rz_io_map_depriorize()

RZ_API bool rz_io_map_depriorize ( RzIO io,
ut32  id 
)

Definition at line 248 of file io_map.c.

248  {
249  rz_return_val_if_fail(io, false);
250  size_t i;
251  for (i = 0; i < rz_pvector_len(&io->maps); i++) {
252  RzIOMap *map = rz_pvector_at(&io->maps, i);
253  // search for iter with the correct map
254  if (map->id == id) {
255  rz_pvector_remove_at(&io->maps, i);
258  return true;
259  }
260  }
261  return false;
262 }
static void ** rz_pvector_push_front(RzPVector *vec, void *x)
Definition: rz_vector.h:305

References i, io_map_calculate_skyline(), map(), rz_io_t::maps, rz_pvector_at(), rz_pvector_len(), rz_pvector_push_front(), rz_pvector_remove_at(), and rz_return_val_if_fail.

Referenced by rz_open_maps_deprioritize_handler().

◆ rz_io_map_exists()

RZ_API bool rz_io_map_exists ( RzIO io,
RzIOMap map 
)

Definition at line 111 of file io_map.c.

111  {
112  rz_return_val_if_fail(io && map, false);
113  void **it;
114  rz_pvector_foreach (&io->maps, it) {
115  RzIOMap *m = *it;
116  if (!memcmp(m, map, sizeof(RzIOMap))) {
117  return true;
118  }
119  }
120  return false;
121 }

References regress::m, map(), rz_io_t::maps, rz_pvector_foreach, and rz_return_val_if_fail.

◆ rz_io_map_exists_for_id()

RZ_API bool rz_io_map_exists_for_id ( RzIO io,
ut32  id 
)

Definition at line 124 of file io_map.c.

124  {
125  return rz_io_map_resolve(io, id) != NULL;
126 }
RZ_API RzIOMap * rz_io_map_resolve(RzIO *io, ut32 id)
Definition: io_map.c:128

References NULL, and rz_io_map_resolve().

Referenced by rz_open_maps_deprioritize_handler(), and rz_open_maps_prioritize_handler().

◆ rz_io_map_fini()

RZ_API void rz_io_map_fini ( RzIO io)

Definition at line 318 of file io_map.c.

318  {
319  rz_return_if_fail(io);
320  void **it;
321  rz_pvector_foreach (&io->maps, it) {
322  RzIOMap *map = *it;
323  RzEventIOMapDel ev = { map };
325  }
326  rz_pvector_clear(&io->maps);
328  io->map_ids = NULL;
330 }
@ RZ_EVENT_IO_MAP_DEL
Definition: rz_event.h:44
RZ_API void rz_id_pool_free(RzIDPool *pool)
Definition: idpool.c:72
RzIDPool * map_ids
Definition: rz_io.h:72

References rz_io_t::event, map(), rz_io_t::map_ids, rz_io_t::map_skyline, rz_io_t::maps, NULL, RZ_EVENT_IO_MAP_DEL, rz_event_send(), rz_id_pool_free(), rz_pvector_clear(), rz_pvector_foreach, rz_return_if_fail, and rz_skyline_clear().

Referenced by rz_io_fini(), rz_io_map_cleanup(), and rz_io_map_reset().

◆ rz_io_map_get()

◆ rz_io_map_get_for_fd()

RZ_API RzList* rz_io_map_get_for_fd ( RzIO io,
int  fd 
)

Definition at line 388 of file io_map.c.

388  {
389  RzList *map_list = rz_list_newf(NULL);
390  if (!map_list) {
391  return NULL;
392  }
393  void **it;
394  rz_pvector_foreach (&io->maps, it) {
395  RzIOMap *map = *it;
396  if (map && map->fd == fd) {
397  rz_list_append(map_list, map);
398  }
399  }
400  return map_list;
401 }
RZ_API RZ_BORROW RzListIter * rz_list_append(RZ_NONNULL RzList *list, void *data)
Appends at the end of the list a new element.
Definition: list.c:288

References fd, map(), rz_io_t::maps, NULL, rz_list_append(), rz_list_newf(), and rz_pvector_foreach.

Referenced by DEFINE_HANDLE_TS_FCN_AND_SYMBOL(), rz_core_cmd_foreach3(), rz_core_raw_file_print(), rz_io_bind(), rz_io_map_remap_fd(), and rz_io_resize().

◆ rz_io_map_get_paddr()

RZ_API RzIOMap* rz_io_map_get_paddr ( RzIO io,
ut64  paddr 
)

Definition at line 163 of file io_map.c.

163  {
165  void **it;
166  rz_pvector_foreach_prev(&io->maps, it) {
167  RzIOMap *map = *it;
168  if (map->delta <= paddr && paddr <= map->delta + (map->itv.size ? map->itv.size - 1 : 0)) {
169  return map;
170  }
171  }
172  return NULL;
173 }

References delta, map(), rz_io_t::maps, NULL, rz_pvector_foreach_prev, and rz_return_val_if_fail.

Referenced by rz_core_pava(), rz_io_bind(), and rz_io_p2v().

◆ rz_io_map_init()

RZ_API void rz_io_map_init ( RzIO io)

Definition at line 101 of file io_map.c.

101  {
102  rz_return_if_fail(io);
104  if (io->map_ids) {
106  }
108 }
static void map_free(void *p)
Free-only. Be careful to only call this after sending RZ_EVENT_IO_MAP_DEL! (map_del does this)
Definition: io_map.c:84
#define END_OF_MAP_IDS
Definition: io_map.c:11
RZ_API RzIDPool * rz_id_pool_new(ut32 start_id, ut32 last_id)
Definition: idpool.c:22

References END_OF_MAP_IDS, map_free(), rz_io_t::map_ids, rz_io_t::maps, rz_id_pool_free(), rz_id_pool_new(), rz_pvector_init(), and rz_return_if_fail.

Referenced by rz_io_init(), rz_io_map_cleanup(), and rz_io_map_reset().

◆ rz_io_map_is_mapped()

RZ_API bool rz_io_map_is_mapped ( RzIO io,
ut64  addr 
)

Definition at line 181 of file io_map.c.

181  {
182  rz_return_val_if_fail(io, false);
183  return (bool)rz_io_map_get(io, addr);
184 }
RZ_API RzIOMap * rz_io_map_get(RzIO *io, ut64 addr)
Definition: io_map.c:176

References addr, rz_io_map_get(), and rz_return_val_if_fail.

Referenced by bp_is_mapped().

◆ rz_io_map_location()

RZ_API ut64 rz_io_map_location ( RzIO io,
ut64  size 
)

Returns a memory location that can hold enough bytes without overlapping.

Parameters
ioRzIO instance
sizeSize of the section

Definition at line 425 of file io_map.c.

425  {
426  ut64 base = (io->bits == 64) ? 0x60000000000ULL : 0x60000000ULL;
427  return rz_io_map_next_available(io, base, size, 0x200000);
428 }
RZ_API ut64 rz_io_map_next_available(RzIO *io, ut64 addr, ut64 size, ut64 load_align)
Definition: io_map.c:347
int bits
Definition: rz_io.h:62

References rz_io_t::bits, rz_io_map_next_available(), and ut64().

Referenced by rz_core_bin_load().

◆ rz_io_map_new()

RZ_API RzIOMap* rz_io_map_new ( RzIO io,
int  fd,
int  flags,
ut64  delta,
ut64  addr,
ut64  size 
)

Definition at line 50 of file io_map.c.

50  {
51  return io_map_new(io, fd, perm, delta, addr, size);
52 }
RzIOMap * io_map_new(RzIO *io, int fd, int perm, ut64 delta, ut64 addr, ut64 size)
Definition: io_map.c:24

References addr, delta, fd, and io_map_new().

Referenced by handle_tmp_desc(), perform_mapped_file_yank(), rz_core_bin_load(), rz_core_cmd_subst_i(), rz_debug_dmp_init(), rz_io_map_remap(), rz_io_map_resize(), rz_io_open(), rz_io_open_at(), and rz_main_rizin().

◆ rz_io_map_next_address()

RZ_API ut64 rz_io_map_next_address ( RzIO io,
ut64  addr 
)

Definition at line 371 of file io_map.c.

371  {
372  ut64 lowest = UT64_MAX;
373  void **it;
374  rz_pvector_foreach (&io->maps, it) {
375  RzIOMap *map = *it;
376  ut64 from = rz_itv_begin(map->itv);
377  if (from > addr && addr < lowest) {
378  lowest = from;
379  }
380  ut64 to = rz_itv_end(map->itv);
381  if (to > addr && to < lowest) {
382  lowest = to;
383  }
384  }
385  return lowest;
386 }
static ut64 rz_itv_end(RzInterval itv)
Definition: rz_itv.h:42

References addr, from, map(), rz_io_t::maps, rz_itv_begin(), rz_itv_end(), rz_pvector_foreach, to, ut64(), and UT64_MAX.

Referenced by rz_core_search_value_in_range().

◆ rz_io_map_next_available()

RZ_API ut64 rz_io_map_next_available ( RzIO io,
ut64  addr,
ut64  size,
ut64  load_align 
)

Definition at line 347 of file io_map.c.

347  {
348  if (load_align == 0) {
349  load_align = 1;
350  }
351  void **it;
352  ut64 next_addr = addr,
353  end_addr = next_addr + size;
354  rz_pvector_foreach (&io->maps, it) {
355  RzIOMap *map = *it;
356  if (!rz_itv_size(map->itv)) {
357  break;
358  }
359  ut64 to = rz_itv_end(map->itv);
360  next_addr = RZ_MAX(next_addr, to + (load_align - (to % load_align)) % load_align);
361  if ((map->itv.addr <= next_addr && next_addr < to) || rz_itv_contain(map->itv, end_addr)) {
362  next_addr = to + (load_align - (to % load_align)) % load_align;
363  continue;
364  }
365  break;
366  }
367  return next_addr;
368 }
static bool rz_itv_contain(RzInterval itv, ut64 addr)
Definition: rz_itv.h:52

References addr, map(), rz_io_t::maps, rz_itv_contain(), rz_itv_end(), rz_itv_size(), RZ_MAX, rz_pvector_foreach, to, and ut64().

Referenced by get_esil_stack_name(), perform_mapped_file_yank(), and rz_io_map_location().

◆ rz_io_map_priorize()

RZ_API bool rz_io_map_priorize ( RzIO io,
ut32  id 
)

Definition at line 232 of file io_map.c.

232  {
233  rz_return_val_if_fail(io, false);
234  size_t i;
235  for (i = 0; i < rz_pvector_len(&io->maps); i++) {
236  RzIOMap *map = rz_pvector_at(&io->maps, i);
237  // search for iter with the correct map
238  if (map->id == id) {
239  rz_pvector_remove_at(&io->maps, i);
240  rz_pvector_push(&io->maps, map);
241  rz_skyline_add(&io->map_skyline, map->itv, map);
242  return true;
243  }
244  }
245  return false;
246 }

References i, map(), rz_io_t::map_skyline, rz_io_t::maps, rz_pvector_at(), rz_pvector_len(), rz_pvector_push(), rz_pvector_remove_at(), rz_return_val_if_fail, and rz_skyline_add().

Referenced by rz_open_maps_prioritize_binid_handler(), and rz_open_maps_prioritize_handler().

◆ rz_io_map_priorize_for_fd()

RZ_API bool rz_io_map_priorize_for_fd ( RzIO io,
int  fd 
)

Definition at line 264 of file io_map.c.

264  {
265  rz_return_val_if_fail(io, false);
266  // we need a clean list for this, or this becomes a segfault-field
267  rz_io_map_cleanup(io);
268  RzPVector temp;
269  rz_pvector_init(&temp, NULL);
270  size_t i;
271  for (i = 0; i < rz_pvector_len(&io->maps);) {
272  RzIOMap *map = rz_pvector_at(&io->maps, i);
273  if (map->fd == fd) {
274  rz_pvector_push(&temp, map);
275  rz_pvector_remove_at(&io->maps, i);
276  continue;
277  }
278  i++;
279  }
280  rz_pvector_insert_range(&io->maps, rz_pvector_len(&io->maps), temp.v.a, rz_pvector_len(&temp));
281  rz_pvector_clear(&temp);
283  return true;
284 }
RZ_API void rz_io_map_cleanup(RzIO *io)
Definition: io_map.c:287
static void ** rz_pvector_insert_range(RzPVector *vec, size_t index, void **first, size_t count)
Definition: rz_vector.h:289
RzVector v
Definition: rz_vector.h:56

References rz_vector_t::a, fd, i, io_map_calculate_skyline(), map(), rz_io_t::maps, NULL, rz_io_map_cleanup(), rz_pvector_at(), rz_pvector_clear(), rz_pvector_init(), rz_pvector_insert_range(), rz_pvector_len(), rz_pvector_push(), rz_pvector_remove_at(), rz_return_val_if_fail, and rz_pvector_t::v.

Referenced by rz_open_maps_prioritize_fd_handler().

◆ rz_io_map_remap()

RZ_API bool rz_io_map_remap ( RzIO io,
ut32  id,
ut64  addr 
)

Definition at line 54 of file io_map.c.

54  {
55  RzIOMap *map = rz_io_map_resolve(io, id);
56  if (map) {
57  ut64 size = map->itv.size;
58  map->itv.addr = addr;
59  if (size && UT64_MAX - size + 1 < addr) {
60  map->itv.size = -addr;
61  rz_io_map_new(io, map->fd, map->perm, map->delta - addr, 0, size + addr);
62  }
64  return true;
65  }
66  return false;
67 }
RZ_API RzIOMap * rz_io_map_new(RzIO *io, int fd, int perm, ut64 delta, ut64 addr, ut64 size)
Definition: io_map.c:50

References addr, io_map_calculate_skyline(), map(), rz_io_map_new(), rz_io_map_resolve(), ut64(), and UT64_MAX.

Referenced by rz_debug_dmp_init(), rz_io_map_remap_fd(), rz_open_maps_relocate_current_handler(), and rz_open_maps_relocate_handler().

◆ rz_io_map_remap_fd()

RZ_API bool rz_io_map_remap_fd ( RzIO io,
int  fd,
ut64  addr 
)

Definition at line 69 of file io_map.c.

69  {
70  RzIOMap *map;
71  bool retval = false;
73  if (maps) {
74  map = rz_list_get_n(maps, 0);
75  if (map) {
76  retval = rz_io_map_remap(io, map->id, addr);
77  }
79  }
80  return retval;
81 }
static RzList * maps(RzBinFile *bf)
Definition: bin_bf.c:116
RZ_API bool rz_io_map_remap(RzIO *io, ut32 id, ut64 addr)
Definition: io_map.c:54
RZ_API RzList * rz_io_map_get_for_fd(RzIO *io, int fd)
Definition: io_map.c:388
RZ_API RZ_BORROW void * rz_list_get_n(RZ_NONNULL const RzList *list, ut32 n)
Returns the N-th element of the list.
Definition: list.c:574

References addr, fd, map(), maps(), rz_io_map_get_for_fd(), rz_io_map_remap(), rz_list_free(), and rz_list_get_n().

Referenced by rz_io_bind().

◆ rz_io_map_reset()

RZ_API void rz_io_map_reset ( RzIO io)

Definition at line 186 of file io_map.c.

186  {
187  rz_io_map_fini(io);
188  rz_io_map_init(io);
190 }

References io_map_calculate_skyline(), rz_io_map_fini(), and rz_io_map_init().

Referenced by rz_io_close_all(), and rz_open_maps_remove_all_handler().

◆ rz_io_map_resize()

RZ_API bool rz_io_map_resize ( RzIO io,
ut32  id,
ut64  newsize 
)

Definition at line 403 of file io_map.c.

403  {
404  RzIOMap *map;
405  if (!(map = rz_io_map_resolve(io, id))) {
406  return false;
407  }
408  ut64 addr = map->itv.addr;
409  if (newsize && UT64_MAX - newsize + 1 < addr) {
410  map->itv.size = -addr;
411  rz_io_map_new(io, map->fd, map->perm, map->delta - addr, 0, newsize + addr);
412  return true;
413  }
414  map->itv.size = newsize;
416  return true;
417 }

References addr, io_map_calculate_skyline(), map(), rz_io_map_new(), rz_io_map_resolve(), ut64(), and UT64_MAX.

Referenced by rz_io_resize(), and rz_open_maps_resize_handler().

◆ rz_io_map_resolve()

RZ_API RzIOMap* rz_io_map_resolve ( RzIO io,
ut32  id 
)

Definition at line 128 of file io_map.c.

128  {
129  rz_return_val_if_fail(io && id, false);
130  void **it;
131  rz_pvector_foreach (&io->maps, it) {
132  RzIOMap *map = *it;
133  if (map->id == id) {
134  return map;
135  }
136  }
137  return NULL;
138 }

References map(), rz_io_t::maps, NULL, rz_pvector_foreach, and rz_return_val_if_fail.

Referenced by rz_io_map_exists_for_id(), rz_io_map_remap(), rz_io_map_resize(), rz_open_maps_flags_handler(), rz_open_maps_name_id_del_handler(), and rz_open_maps_name_id_handler().

◆ rz_io_map_set_name()

RZ_API void rz_io_map_set_name ( RzIOMap map,
const char *  name 
)

Definition at line 332 of file io_map.c.

332  {
333  if (!map || !name) {
334  return;
335  }
336  free(map->name);
337  map->name = strdup(name);
338 }
Definition: z80asm.h:102

References free(), map(), and strdup().

Referenced by ds_init(), rz_core_analysis_esil_init_mem(), rz_open_maps_all_fd_handler(), rz_open_maps_map_fd_handler(), rz_open_maps_map_handler(), rz_open_maps_name_handler(), and rz_open_maps_name_id_handler().

◆ rz_io_maps()

◆ rz_io_new()

RZ_API RzIO* rz_io_new ( void  )

Definition at line 110 of file io.c.

110  {
111  return rz_io_init(RZ_NEW0(RzIO));
112 }
RZ_API RzIO * rz_io_init(RzIO *io)
Definition: io.c:114

References rz_io_init(), and RZ_NEW0.

Referenced by download_pdb(), hash_context_run(), rz_core_init(), rz_diff_io_open(), and rzfind_open_file().

◆ rz_io_nread_at()

RZ_API int rz_io_nread_at ( RzIO io,
ut64  addr,
ut8 buf,
int  len 
)

Definition at line 338 of file io.c.

338  {
339  int ret;
340  rz_return_val_if_fail(io && buf && len >= 0, -1);
341  if (len == 0) {
342  return 0;
343  }
344  if (io->va) {
345  if (io->ff) {
346  memset(buf, io->Oxff, len);
347  }
348  ret = on_map_skyline(io, addr, buf, len, RZ_PERM_R, fd_read_at_wrap, true);
349  } else {
350  ret = rz_io_pread_at(io, addr, buf, len);
351  }
352  if (ret > 0 && io->cached & RZ_PERM_R) {
353  (void)rz_io_cache_read(io, addr, buf, len);
354  }
355  return ret;
356 }
static int fd_read_at_wrap(RzIO *io, int fd, ut64 addr, ut8 *buf, int len, RzIOMap *map, void *user)
Definition: io.c:18
static st64 on_map_skyline(RzIO *io, ut64 vaddr, ut8 *buf, int len, int match_flg, cbOnIterMap op, bool prefix_mode)
Definition: io.c:30
return memset(p, 0, total)
int ff
Definition: rz_io.h:64
int Oxff
Definition: rz_io.h:65

References addr, rz_io_t::cached, fd_read_at_wrap(), rz_io_t::ff, len, memset(), on_map_skyline(), rz_io_t::Oxff, rz_io_cache_read(), rz_io_pread_at(), RZ_PERM_R, rz_return_val_if_fail, and rz_io_t::va.

Referenced by core_recover_golang_functions_go_1_16(), core_recover_golang_functions_go_1_18(), core_recover_golang_functions_go_1_2(), decode_from_table(), decode_ldr_set_addr(), GH(), go_offset(), op_at_phys(), read_at_kernel_virtual(), recover_string_at(), rizin_compare_words(), rz_cmd_cmp_hex_block_handler(), rz_cmd_cmp_hex_block_hexdiff_handler(), rz_cmd_cmp_hex_diff_lines_handler(), rz_cmd_heap_chunks_print_handler(), rz_core_analysis_recover_golang_functions(), rz_core_analysis_resolve_golang_strings(), rz_core_cmp_disasm(), rz_core_cmp_mem_data(), rz_core_cmp_mem_mem(), rz_core_cmpwatch_add(), rz_core_cmpwatch_update(), rz_core_transform_op(), rz_core_write_duplicate_at(), rz_heap_tcache_content(), and type_match().

◆ rz_io_open()

RZ_API RzIODesc* rz_io_open ( RzIO io,
const char *  uri,
int  flags,
int  mode 
)

Definition at line 156 of file io.c.

156  {
158  RzIODesc *desc = rz_io_open_nomap(io, uri, perm, mode);
159  if (!desc) {
160  return NULL;
161  }
162  rz_io_map_new(io, desc->fd, desc->perm, 0LL, 0LL, rz_io_desc_size(desc));
163  return desc;
164 }
RZ_API RzIOMap * rz_io_map_new(RzIO *io, int fd, int flags, ut64 delta, ut64 addr, ut64 size)
Definition: io_map.c:50

References desc, NULL, rz_io_desc_size(), rz_io_map_new(), rz_io_open_nomap(), and rz_return_val_if_fail.

Referenced by rz_open_binary_file_handler().

◆ rz_io_open_at()

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.

This executes both rz_io_open_nomap() and rz_io_map_new() and returns their results without updating the skyline.

Parameters
urifile uri to open
atwhere to map the file
mapoptionally returns the created RzIOMap
Returns
the opened RzIODesc of the file

Definition at line 177 of file io.c.

177  {
178  rz_return_val_if_fail(io && uri, NULL);
179 
180  RzIODesc *desc = rz_io_open_nomap(io, uri, perm, mode);
181  if (!desc) {
182  return NULL;
183  }
185  // second map
186  if (size && ((UT64_MAX - size + 1) < at)) {
187  // split map into 2 maps if only 1 big map results into interger overflow
188  io_map_new(io, desc->fd, desc->perm, UT64_MAX - at + 1, 0LL, size - (UT64_MAX - at) - 1);
189  // someone pls take a look at this confusing stuff
190  size = UT64_MAX - at + 1;
191  }
192  // skyline not updated
193  RzIOMap *m = rz_io_map_new(io, desc->fd, desc->perm, 0LL, at, size);
194  if (map) {
195  *map = m;
196  }
197  return desc;
198 }

References desc, io_map_new(), regress::m, map(), NULL, rz_io_desc_size(), rz_io_map_new(), rz_io_open_nomap(), rz_return_val_if_fail, ut64(), and UT64_MAX.

Referenced by io_create_mem_map(), open_nobin_file(), and rz_io_bind().

◆ rz_io_open_buffer()

RZ_API RzIODesc* rz_io_open_buffer ( RzIO io,
RzBuffer b,
int  flags,
int  mode 
)

Definition at line 133 of file io.c.

133  {
134  ut64 bufSize = rz_buf_size(b);
135  char *uri = rz_str_newf("malloc://%" PFMT64d, bufSize);
136  RzIODesc *desc = rz_io_open_nomap(io, uri, perm, mode);
137  if (desc) {
138  const ut8 *tmp = rz_buf_data(b, &bufSize);
139  rz_io_desc_write(desc, tmp, bufSize);
140  }
141  free(uri);
142  return desc;
143 }
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.
Definition: buf.c:1287
RZ_API ut64 rz_buf_size(RZ_NONNULL RzBuffer *b)
Return the size of the buffer.
Definition: buf.c:1225
RZ_API char * rz_str_newf(const char *fmt,...) RZ_PRINTF_CHECK(1
#define PFMT64d
Definition: rz_types.h:394
#define b(i)
Definition: sha256.c:42

References b, desc, free(), PFMT64d, rz_buf_data(), rz_buf_size(), rz_io_desc_write(), rz_io_open_nomap(), rz_str_newf(), autogen_x86imm::tmp, and ut64().

Referenced by handle_tmp_desc(), and rz_core_cmd_subst_i().

◆ rz_io_open_many()

RZ_API RzList* rz_io_open_many ( RzIO io,
const char *  uri,
int  flags,
int  mode 
)

Definition at line 201 of file io.c.

201  {
202  RzList *desc_list;
203  RzListIter *iter;
204  RzIODesc *desc;
205  rz_return_val_if_fail(io && io->files && uri, NULL);
206  RzIOPlugin *plugin = rz_io_plugin_resolve(io, uri, 1);
207  if (!plugin || !plugin->open_many || !plugin->close) {
208  return NULL;
209  }
210  if (!(desc_list = plugin->open_many(io, uri, perm, mode))) {
211  return NULL;
212  }
213  rz_list_foreach (desc_list, iter, desc) {
214  if (desc) {
215  if (!desc->plugin) {
216  desc->plugin = plugin;
217  }
218  if (!desc->uri) {
219  desc->uri = strdup(uri);
220  }
221  // should autofd be honored here?
222  rz_io_desc_add(io, desc);
223  if (!io->desc) {
224  io->desc = desc;
225  }
226  }
227  }
228  return desc_list;
229 }
RZ_API bool rz_io_desc_add(RzIO *io, RzIODesc *desc)
Definition: io_desc.c:49
int(* close)(RzIODesc *desc)
Definition: rz_io.h:132
RzList *(* open_many)(RzIO *io, const char *, int perm, int mode)
Definition: rz_io.h:128

References rz_io_plugin_t::close, desc, rz_io_t::desc, rz_io_t::files, NULL, rz_io_plugin_t::open_many, rz_io_desc_add(), rz_io_plugin_resolve(), rz_return_val_if_fail, and strdup().

Referenced by rz_core_file_open_many().

◆ rz_io_open_nomap()

RZ_API RzIODesc* rz_io_open_nomap ( RzIO io,
const char *  uri,
int  flags,
int  mode 
)

Definition at line 145 of file io.c.

145  {
146  rz_return_val_if_fail(io && uri, NULL);
147  RzIODesc *desc = rz_io_desc_open(io, uri, perm, mode);
148  if ((io->autofd || !io->desc) && desc) {
149  io->desc = desc;
150  }
151  // set desc as current if autofd or io->desc==NULL
152  return desc;
153 }
int autofd
Definition: rz_io.h:68

References rz_io_t::autofd, desc, rz_io_t::desc, NULL, rz_io_desc_open(), and rz_return_val_if_fail.

Referenced by add_map(), hash_context_create_desc_io_stdin(), hash_context_create_desc_io_string(), hash_context_run(), perform_mapped_file_yank(), reopen_in_malloc_cb(), rz_core_file_open(), rz_core_rtr_rap_run(), rz_diff_io_open(), rz_io_bind(), rz_io_open(), rz_io_open_at(), rz_io_open_buffer(), rz_io_reopen(), and rzfind_open_file().

◆ rz_io_p2v()

RZ_API ut64 rz_io_p2v ( RzIO io,
ut64  pa 
)

Definition at line 533 of file io.c.

533  {
534  RzIOMap *map = rz_io_map_get_paddr(io, pa);
535  if (map) {
536  return pa - map->delta + map->itv.addr;
537  }
538  return UT64_MAX;
539 }

References map(), rz_io_map_get_paddr(), and UT64_MAX.

Referenced by annotated_hexdump(), rz_cmd_help(), rz_io_bind(), and rz_print_hexdump_bits_handler().

◆ rz_io_plugin_add()

RZ_API bool rz_io_plugin_add ( RzIO io,
RZ_BORROW RzIOPlugin plugin 
)

Definition at line 12 of file io_plugin.c.

12  {
13  if (!io || !io->plugins || !plugin || !plugin->name) {
14  return false;
15  }
16  RzListIter *it;
17  RzIOPlugin *nplugin;
18  rz_list_foreach (io->plugins, it, nplugin) {
19  if (!strcmp(nplugin->name, plugin->name)) {
20  return false;
21  }
22  }
23  nplugin = RZ_NEW0(RzIOPlugin);
24  if (!nplugin) {
25  return false;
26  }
27  memcpy(nplugin, plugin, sizeof(RzIOPlugin));
28  rz_list_append(io->plugins, nplugin);
29  return true;
30 }
const char * name
Definition: rz_io.h:115

References memcpy(), rz_io_plugin_t::name, rz_io_t::plugins, rz_list_append(), and RZ_NEW0.

Referenced by rz_core_init(), and rz_io_plugin_init().

◆ rz_io_plugin_get_default()

RZ_API RzIOPlugin* rz_io_plugin_get_default ( RzIO io,
const char *  filename,
bool  many 
)

Definition at line 47 of file io_plugin.c.

47  {
48  if (!default_plugin || !default_plugin->check || !default_plugin->check(io, filename, many)) {
49  return NULL;
50  }
51  return (RzIOPlugin *)default_plugin;
52 }
static volatile RzIOPlugin * default_plugin
Definition: io_plugin.c:8
const char * filename
Definition: ioapi.h:137

References rz_io_plugin_t::check, default_plugin, and NULL.

Referenced by rz_io_plugin_byname(), and rz_io_plugin_resolve().

◆ rz_io_plugin_init()

RZ_API bool rz_io_plugin_init ( RzIO io)

Definition at line 32 of file io_plugin.c.

32  {
33  int i;
34  if (!io) {
35  return false;
36  }
37  io->plugins = rz_list_newf(free);
38  for (i = 0; i < RZ_ARRAY_SIZE(io_static_plugins); i++) {
39  if (!io_static_plugins[i]->name) {
40  continue;
41  }
43  }
44  return true;
45 }
static RzIOPlugin * io_static_plugins[]
Definition: io_plugin.c:10
RZ_API bool rz_io_plugin_add(RzIO *io, RZ_BORROW RzIOPlugin *plugin)
Definition: io_plugin.c:12
#define RZ_ARRAY_SIZE(x)
Definition: rz_types.h:300

References free(), i, io_static_plugins, rz_io_t::plugins, RZ_ARRAY_SIZE, rz_io_plugin_add(), and rz_list_newf().

Referenced by rz_io_init().

◆ rz_io_plugin_read()

RZ_API int rz_io_plugin_read ( RzIODesc desc,
ut8 buf,
int  len 
)

Definition at line 79 of file io_plugin.c.

79  {
80  if (!buf || !desc || !desc->plugin || len < 1 || !(desc->perm & RZ_PERM_R)) {
81  return 0;
82  }
83  if (!desc->plugin->read) {
84  return -1;
85  }
86  return desc->plugin->read(desc->io, desc, buf, len);
87 }

References desc, len, and RZ_PERM_R.

Referenced by rz_io_desc_read(), and rz_io_plugin_read_at().

◆ rz_io_plugin_read_at()

RZ_API int rz_io_plugin_read_at ( RzIODesc desc,
ut64  addr,
ut8 buf,
int  len 
)

Definition at line 103 of file io_plugin.c.

103  {
105  return rz_io_plugin_read(desc, buf, len);
106  }
107  return 0;
108 }
RZ_API int rz_io_plugin_read(RzIODesc *desc, ut8 *buf, int len)
Definition: io_plugin.c:79

References addr, desc, len, rz_io_desc_is_chardevice(), rz_io_desc_seek(), rz_io_plugin_read(), and RZ_IO_SEEK_SET.

◆ rz_io_plugin_resolve()

RZ_API RzIOPlugin* rz_io_plugin_resolve ( RzIO io,
const char *  filename,
bool  many 
)

Definition at line 54 of file io_plugin.c.

54  {
56  RzIOPlugin *ret;
57  rz_list_foreach (io->plugins, iter, ret) {
58  if (!ret || !ret->check) {
59  continue;
60  }
61  if (ret->check(io, filename, many)) {
62  return ret;
63  }
64  }
65  return rz_io_plugin_get_default(io, filename, many);
66 }
RZ_API RzIOPlugin * rz_io_plugin_get_default(RzIO *io, const char *filename, bool many)
Definition: io_plugin.c:47

References rz_io_plugin_t::check, rz_io_t::plugins, and rz_io_plugin_get_default().

Referenced by dmp_open(), rz_io_desc_open(), and rz_io_open_many().

◆ rz_io_plugin_write()

RZ_API int rz_io_plugin_write ( RzIODesc desc,
const ut8 buf,
int  len 
)

Definition at line 89 of file io_plugin.c.

89  {
90  if (!buf || !desc || !desc->plugin || len < 1 || !(desc->perm & RZ_PERM_W)) {
91  return 0;
92  }
93  if (!desc->plugin->write) {
94  return -1;
95  }
96  const ut64 cur_addr = rz_io_desc_seek(desc, 0LL, RZ_IO_SEEK_CUR);
97  int ret = desc->plugin->write(desc->io, desc, buf, len);
98  RzEventIOWrite iow = { cur_addr, buf, len };
99  rz_event_send(desc->io->event, RZ_EVENT_IO_WRITE, &iow);
100  return ret;
101 }

References desc, len, RZ_EVENT_IO_WRITE, rz_event_send(), rz_io_desc_seek(), RZ_IO_SEEK_CUR, RZ_PERM_W, and ut64().

Referenced by rz_io_desc_write(), and rz_io_plugin_write_at().

◆ rz_io_plugin_write_at()

RZ_API int rz_io_plugin_write_at ( RzIODesc desc,
ut64  addr,
const ut8 buf,
int  len 
)

Definition at line 110 of file io_plugin.c.

110  {
112  return rz_io_plugin_write(desc, buf, len);
113  }
114  return 0;
115 }
RZ_API int rz_io_plugin_write(RzIODesc *desc, const ut8 *buf, int len)
Definition: io_plugin.c:89

References addr, desc, len, rz_io_desc_is_chardevice(), rz_io_desc_seek(), rz_io_plugin_write(), and RZ_IO_SEEK_SET.

◆ rz_io_pread_at()

◆ rz_io_pwrite_at()

RZ_API int rz_io_pwrite_at ( RzIO io,
ut64  paddr,
const ut8 buf,
int  len 
)

◆ rz_io_read()

RZ_API bool rz_io_read ( RzIO io,
ut8 buf,
int  len 
)

Definition at line 383 of file io.c.

383  {
384  if (io && rz_io_read_at(io, io->off, buf, len)) {
385  io->off += len;
386  return true;
387  }
388  return false;
389 }
ut64 off
Definition: rz_io.h:61

References len, rz_io_t::off, and rz_io_read_at().

◆ rz_io_read_at()

RZ_API bool rz_io_read_at ( RzIO io,
ut64  addr,
ut8 buf,
int  len 
)

Definition at line 300 of file io.c.

300  {
301  rz_return_val_if_fail(io && buf && len >= 0, false);
302  if (len == 0) {
303  return false;
304  }
305  bool ret = (io->va)
307  : rz_io_pread_at(io, addr, buf, len) > 0;
308  if (io->cached & RZ_PERM_R) {
309  (void)rz_io_cache_read(io, addr, buf, len);
310  }
311  return ret;
312 }
RZ_API bool rz_io_vread_at_mapped(RzIO *io, ut64 vaddr, ut8 *buf, int len)
Definition: io.c:283

References addr, rz_io_t::cached, len, rz_io_cache_read(), rz_io_pread_at(), rz_io_vread_at_mapped(), RZ_PERM_R, rz_return_val_if_fail, and rz_io_t::va.

Referenced by __analysis_esil_function(), __core_cmd_search_asm_byteswap(), __core_cmd_search_asm_infinite(), _analysis_calls(), _cb_hit(), cmd_aea(), cmd_debug_backtrace(), cmd_p_minus_e(), cmd_print_bars(), cmd_print_pxA(), cmd_write_bits(), core_analysis_graph_construct_nodes(), core_walk_function_blocks(), disassembly_as_table(), do_analysis_search(), do_debug_trace_calls(), do_ref_search(), do_section_search(), do_string_search(), do_syscall_search(), ds_print_ptr(), ds_show_refs(), dump_maps(), esilbreak_mem_read(), func_walk_blocks(), get_ptr(), get_ptr_ble(), getpcfromstack(), graph_construct_nodes(), ioMemcpy(), is_string_at(), jemalloc_get_bins(), jemalloc_get_chunks(), jemalloc_print_narenas(), meta_string_8bit_add(), myregwrite(), num_callback(), objc_build_refs(), perform_mapped_file_yank(), prevop_addr(), print_cmd_analysis_after_traps_print(), print_double_linked_list_bin_graph(), print_double_linked_list_bin_simple(), print_format_values(), print_heap_chunk(), print_malloc_info(), print_rop(), propagate_types_among_used_variables(), readDword(), readQword(), rz_analysis_try_get_fcn(), rz_analysis_xrefs_from_list_handler(), rz_cmd_analysis(), rz_cmd_debug_step_prog_handler(), rz_cmd_disassemble_ropchain_handler(), rz_cmd_disassembly_basic_block_as_text_json_handler(), rz_cmd_disassembly_basic_block_handler(), rz_cmd_disassembly_function_handler(), rz_cmd_print(), rz_core_analysis_bytes(), rz_core_analysis_data(), rz_core_analysis_esil(), rz_core_analysis_esil_emulate(), rz_core_analysis_hasrefs_to_depth(), rz_core_analysis_hint_set_offset(), rz_core_analysis_name(), rz_core_analysis_op(), rz_core_analysis_read_at(), rz_core_analysis_rename(), rz_core_analysis_search(), rz_core_analysis_search_xrefs(), rz_core_arg_get(), rz_core_asm_back_disassemble(), rz_core_asm_back_disassemble_all(), rz_core_asm_bwdisassemble(), rz_core_asm_strsearch(), rz_core_bin_export_info(), rz_core_bin_whole_strings(), rz_core_block_read(), rz_core_debug_step_skip(), rz_core_disasm_instruction(), rz_core_dump(), rz_core_esil_step(), rz_core_link_stroff(), rz_core_op_analysis(), rz_core_op_str(), rz_core_print_disasm(), rz_core_print_disasm_all(), rz_core_print_dump_str(), rz_core_print_function_disasm_json(), rz_core_print_hexdump_byline_str(), rz_core_print_hexdump_diff_str(), rz_core_print_hexdump_or_hexdiff_str(), rz_core_rtr_gdb_cb(), rz_core_search_cb(), rz_core_search_prelude(), rz_core_search_rop(), rz_core_shift_block(), rz_core_syscall_as_string(), rz_core_visual_asm(), rz_core_yank(), rz_core_yank_string(), rz_heap_bin_content(), rz_heap_chunks_list(), rz_heap_fastbin_content(), rz_heap_update_main_arena(), rz_io_bind(), rz_io_cache_write(), rz_io_read(), rz_io_read_i(), rz_io_shift(), rz_open_malloc_handler(), rz_print_byte_bitstream_handler(), rz_print_hexdump_hexless_words_handler(), rz_write_from_io_xchg_handler(), search_hash(), search_similar_pattern_in(), step_until_inst(), step_until_optype(), stringAt(), tcache_chunk_size(), and tcache_read().

◆ rz_io_read_at_mapped()

RZ_API bool rz_io_read_at_mapped ( RzIO io,
ut64  addr,
ut8 buf,
int  len 
)

Definition at line 318 of file io.c.

318  {
319  bool ret;
320  rz_return_val_if_fail(io && buf, false);
321  if (io->ff) {
322  memset(buf, io->Oxff, len);
323  }
324  if (io->va) {
325  ret = on_map_skyline(io, addr, buf, len, RZ_PERM_R, fd_read_at_wrap, false);
326  } else {
327  ret = rz_io_pread_at(io, addr, buf, len) > 0;
328  }
329  if (io->cached & RZ_PERM_R) {
330  (void)rz_io_cache_read(io, addr, buf, len);
331  }
332  return ret;
333 }

References addr, rz_io_t::cached, fd_read_at_wrap(), rz_io_t::ff, len, memset(), on_map_skyline(), rz_io_t::Oxff, rz_io_cache_read(), rz_io_pread_at(), RZ_PERM_R, rz_return_val_if_fail, and rz_io_t::va.

Referenced by read_ahead(), rz_core_esil_step(), rz_core_search_value_in_range(), and rz_core_write_value_inc_at().

◆ rz_io_read_i()

RZ_API bool rz_io_read_i ( RzIO io,
ut64  addr,
ut64 val,
int  size,
bool  endian 
)

Definition at line 41 of file ioutils.c.

41  {
42  ut8 buf[8];
43  rz_return_val_if_fail(io && val, false);
44  size = RZ_DIM(size, 1, 8);
45  if (!rz_io_read_at(io, addr, buf, size)) {
46  return false;
47  }
48  // size says the number of bytes to read transform to bits for rz_read_ble
49  *val = rz_read_ble(buf, endian, size * 8);
50  return true;
51 }
ut16 val
Definition: armass64_const.h:6
static ut64 rz_read_ble(const void *src, bool big_endian, int size)
Definition: rz_endian.h:517
#define RZ_DIM(x, y, z)

References addr, RZ_DIM, rz_io_read_at(), rz_read_ble(), rz_return_val_if_fail, and val.

Referenced by core_analysis_followptr(), ds_build_op_str(), and rz_core_analysis_bytes().

◆ rz_io_reopen()

RZ_API bool rz_io_reopen ( RzIO io,
int  fd,
int  flags,
int  mode 
)

Definition at line 231 of file io.c.

231  {
232  RzIODesc *old, *new;
233  char *uri;
234  if (!(old = rz_io_desc_get(io, fd))) {
235  return false;
236  }
237  // does this really work, or do we have to handler debuggers ugly
238  uri = old->referer ? old->referer : old->uri;
239 #if __WINDOWS__ // TODO: workaround, see https://github.com/rizinorg/rizin/issues/8840
240  if (old->plugin->close && old->plugin->close(old)) {
241  return false; // TODO: this is an unrecoverable scenario
242  }
243  if (!(new = rz_io_open_nomap(io, uri, perm, mode))) {
244  return false;
245  }
246  rz_io_desc_exchange(io, old->fd, new->fd);
247  rz_io_desc_del(io, old->fd);
248  return true;
249 #else
250  if (!(new = rz_io_open_nomap(io, uri, perm, mode))) {
251  return false;
252  }
253  rz_io_desc_exchange(io, old->fd, new->fd);
254  return rz_io_desc_close(old); // magic
255 #endif // __WINDOWS__
256 }
RZ_API bool rz_io_desc_exchange(RzIO *io, int fd, int fdx)
Definition: io_desc.c:275
RZ_API bool rz_io_desc_del(RzIO *io, int fd)
Definition: io_desc.c:61
char * uri
Definition: rz_io.h:98
char * referer
Definition: rz_io.h:100

References rz_io_plugin_t::close, fd, rz_io_desc_t::fd, rz_io_desc_t::plugin, rz_io_desc_t::referer, rz_io_desc_close(), rz_io_desc_del(), rz_io_desc_exchange(), rz_io_desc_get(), rz_io_open_nomap(), and rz_io_desc_t::uri.

Referenced by rz_core_file_reopen_debug(), rz_core_io_file_open(), and rz_core_io_file_reopen().

◆ rz_io_resize()

RZ_API bool rz_io_resize ( RzIO io,
ut64  newsize 
)

Definition at line 418 of file io.c.

418  {
419  if (io) {
420  RzList *maps = rz_io_map_get_for_fd(io, io->desc->fd);
421  RzIOMap *current_map;
422  RzListIter *iter;
423  ut64 fd_size = rz_io_fd_size(io, io->desc->fd);
424  bool ret = rz_io_desc_resize(io->desc, newsize);
425  if (!ret) {
427  return false;
428  }
429  rz_list_foreach (maps, iter, current_map) {
430  // we just resize map of the same size of its fd
431  if (current_map->itv.size == fd_size) {
432  rz_io_map_resize(io, current_map->id, newsize);
433  }
434  }
436  return true;
437  }
438  return false;
439 }
RZ_API bool rz_io_map_resize(RzIO *io, ut32 id, ut64 newsize)
Definition: io_map.c:403
ut64 size
Definition: rz_itv.h:16
ut32 id
Definition: rz_io.h:148
RzInterval itv
Definition: rz_io.h:149

References rz_io_t::desc, rz_io_desc_t::fd, rz_io_map_t::id, rz_io_map_t::itv, maps(), rz_io_desc_resize(), rz_io_fd_size(), rz_io_map_get_for_fd(), rz_io_map_resize(), rz_list_free(), rz_interval_t::size, and ut64().

Referenced by file_resize(), and rz_io_extend_at().

◆ rz_io_seek()

RZ_API ut64 rz_io_seek ( RzIO io,
ut64  offset,
int  whence 
)

Definition at line 632 of file io.c.

632  {
633  if (!io) {
634  return 0LL;
635  }
636  switch (whence) {
637  case RZ_IO_SEEK_SET:
638  io->off = offset;
639  break;
640  case RZ_IO_SEEK_CUR:
641  io->off += offset;
642  break;
643  case RZ_IO_SEEK_END:
644  default:
645  io->off = rz_io_desc_seek(io->desc, offset, whence);
646  break;
647  }
648  return io->off;
649 }

References rz_io_t::desc, rz_io_t::off, rz_io_desc_seek(), RZ_IO_SEEK_CUR, RZ_IO_SEEK_END, and RZ_IO_SEEK_SET.

Referenced by perform_mapped_file_yank(), rz_core_seek(), and rzfind_open_file().

◆ rz_io_set_write_mask()

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.

Parameters
ioReference to RzIo instance
maskMask to apply
lenNumber of bytes in the mask
Returns
true if the mask was correctly set, false otherwise

Definition at line 517 of file io.c.

517  {
518  rz_return_val_if_fail(io, false);
519  rz_return_val_if_fail(mask || len == 0, false);
520 
521  free(io->write_mask);
522  if (!mask) {
523  io->write_mask = NULL;
524  io->write_mask_len = 0;
525  return true;
526  }
527  io->write_mask = (ut8 *)malloc(len);
528  memcpy(io->write_mask, mask, len);
529  io->write_mask_len = len;
530  return true;
531 }
#define mask()
void * malloc(size_t size)
Definition: malloc.c:123
ut8 * write_mask
Definition: rz_io.h:78
int write_mask_len
Definition: rz_io.h:79

References free(), len, malloc(), mask, memcpy(), NULL, rz_return_val_if_fail, rz_io_t::write_mask, and rz_io_t::write_mask_len.

Referenced by rz_write_mask_reset_handler(), and rz_write_mask_set_handler().

◆ rz_io_shift()

RZ_API bool rz_io_shift ( RzIO io,
ut64  start,
ut64  end,
st64  move 
)

Definition at line 596 of file io.c.

596  {
597  ut8 *buf;
598  ut64 chunksize = 0x10000;
599  ut64 saved_off = io->off;
600  ut64 src, shiftsize = rz_num_abs(move);
601  if (!shiftsize || (end - start) <= shiftsize) {
602  return false;
603  }
604  ut64 rest = (end - start) - shiftsize;
605  if (!(buf = calloc(1, chunksize + 1))) {
606  return false;
607  }
608  if (move > 0) {
609  src = end - shiftsize;
610  } else {
611  src = start + shiftsize;
612  }
613  while (rest > 0) {
614  if (chunksize > rest) {
615  chunksize = rest;
616  }
617  if (move > 0) {
618  src -= chunksize;
619  }
621  rz_io_write_at(io, src + move, buf, chunksize);
622  if (move < 0) {
623  src += chunksize;
624  }
625  rest -= chunksize;
626  }
627  free(buf);
628  io->off = rz_io_desc_seek(io->desc, saved_off, RZ_IO_SEEK_SET);
629  return true;
630 }
lzma_index * src
Definition: index.h:567
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
Definition: sflib.h:133
#define chunksize
static st64 rz_num_abs(st64 num)
Definition: rz_num.h:108

References calloc(), chunksize, rz_io_t::desc, test_evm::end, free(), rz_io_t::off, rz_io_desc_seek(), rz_io_read_at(), RZ_IO_SEEK_SET, rz_io_write_at(), rz_num_abs(), src, start, and ut64().

Referenced by file_resize().

◆ rz_io_size()

RZ_API ut64 rz_io_size ( RzIO io)

Definition at line 399 of file io.c.

399  {
400  // TODO: rethink this, maybe not needed
401  return io ? rz_io_desc_size(io->desc) : 0LL;
402 }

References rz_io_t::desc, and rz_io_desc_size().

Referenced by basefind_create_pointer_map(), core_search_for_xrefs_in_boundaries(), flagbar_foreach(), perform_mapped_file_yank(), rz_basefind(), rz_core_get_boundaries_prot(), rz_core_shift_block(), rz_core_visual_title(), and rzfind_open_file().

◆ rz_io_system()

RZ_API char* rz_io_system ( RzIO io,
const char *  cmd 
)

Definition at line 411 of file io.c.

411  {
412  if (io && io->desc && io->desc->plugin && io->desc->plugin->system && RZ_STR_ISNOTEMPTY(cmd)) {
413  return io->desc->plugin->system(io, io->desc, cmd);
414  }
415  return NULL;
416 }
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
Definition: sflib.h:79
#define RZ_STR_ISNOTEMPTY(x)
Definition: rz_str.h:68
char *(* system)(RzIO *io, RzIODesc *fd, const char *)
Definition: rz_io.h:126

References cmd, rz_io_t::desc, NULL, rz_io_desc_t::plugin, RZ_STR_ISNOTEMPTY, and rz_io_plugin_t::system.

Referenced by __rap_continue(), __rap_reg_profile(), __rap_reg_read(), __rap_step(), cb_dbg_gdb_page_size(), cb_dbg_gdb_retries(), handle_ts_stmt(), rz_cmd_remote(), rz_core_cmd_subst_i(), rz_core_debug_attach(), rz_debug_select(), rz_io_bind(), and rz_io_system_run_oldhandler().

◆ rz_io_update()

RZ_API void rz_io_update ( RzIO io)

Definition at line 159 of file io_map.c.

159  {
161 }

References io_map_calculate_skyline().

◆ rz_io_use_fd()

RZ_API bool rz_io_use_fd ( RzIO io,
int  fd 
)

◆ rz_io_v2p()

RZ_API ut64 rz_io_v2p ( RzIO io,
ut64  va 
)

Definition at line 541 of file io.c.

541  {
542  RzIOMap *map = rz_io_map_get(io, va);
543  if (map) {
544  st64 delta = va - map->itv.addr;
545  return map->delta + delta;
546  }
547  return UT64_MAX;
548 }

References delta, map(), rz_io_map_get(), st64, and UT64_MAX.

Referenced by add_new_bin_string(), add_new_func_symbol(), meta_string_guess_add(), rz_cmd_help(), rz_core_meta_pascal_string_add(), and rz_io_bind().

◆ rz_io_vread_at_mapped()

RZ_API bool rz_io_vread_at_mapped ( RzIO io,
ut64  vaddr,
ut8 buf,
int  len 
)

Definition at line 283 of file io.c.

283  {
284  rz_return_val_if_fail(io && buf && len > 0, false);
285  if (io->ff) {
286  memset(buf, io->Oxff, len);
287  }
288  return on_map_skyline(io, vaddr, buf, len, RZ_PERM_R, fd_read_at_wrap, false);
289 }

References fd_read_at_wrap(), rz_io_t::ff, len, memset(), on_map_skyline(), rz_io_t::Oxff, RZ_PERM_R, and rz_return_val_if_fail.

Referenced by rz_io_read_at().

◆ rz_io_write()

RZ_API bool rz_io_write ( RzIO io,
const ut8 buf,
int  len 
)

Definition at line 391 of file io.c.

391  {
392  if (io && buf && len > 0 && rz_io_write_at(io, io->off, buf, len)) {
393  io->off += len;
394  return true;
395  }
396  return false;
397 }

References len, rz_io_t::off, and rz_io_write_at().

◆ rz_io_write_at()

RZ_API bool rz_io_write_at ( RzIO io,
ut64  addr,
const ut8 buf,
int  len 
)

Definition at line 358 of file io.c.

358  {
359  int i;
360  bool ret = false;
361  ut8 *mybuf = (ut8 *)buf;
362  rz_return_val_if_fail(io && buf && len > 0, false);
363  if (io->write_mask) {
364  mybuf = rz_mem_dup((void *)buf, len);
365  for (i = 0; i < len; i++) {
366  // TODO: this needs some love because it is not optimal.
367  mybuf[i] &= io->write_mask[i % io->write_mask_len];
368  }
369  }
370  if (io->cached & RZ_PERM_W) {
371  ret = rz_io_cache_write(io, addr, mybuf, len);
372  } else if (io->va) {
373  ret = rz_io_vwrite_at(io, addr, mybuf, len);
374  } else {
375  ret = rz_io_pwrite_at(io, addr, mybuf, len) > 0;
376  }
377  if (buf != mybuf) {
378  free(mybuf);
379  }
380  return ret;
381 }
static bool rz_io_vwrite_at(RzIO *io, ut64 vaddr, const ut8 *buf, int len)
Definition: io.c:291
RZ_API void * rz_mem_dup(const void *s, int l)
Definition: mem.c:319

References addr, rz_io_t::cached, free(), i, len, rz_io_cache_write(), rz_io_pwrite_at(), rz_io_vwrite_at(), rz_mem_dup(), RZ_PERM_W, rz_return_val_if_fail, rz_io_t::va, rz_io_t::write_mask, and rz_io_t::write_mask_len.

Referenced by ioMemcpy(), op_at_phys(), rz_cmd_debug_dml_handler(), rz_core_shift_block(), rz_core_visual_asm(), rz_core_visual_cmd(), rz_core_write_at(), rz_heap_write_heap_chunk(), rz_io_bind(), rz_io_cache_commit(), rz_io_cache_invalidate(), rz_io_shift(), rz_io_write(), rz_io_write_i(), rz_main_rizin(), rz_write_from_file_handler(), rz_write_from_io_xchg_handler(), rz_write_from_socket_handler(), and rzfind_open_file().

◆ rz_io_write_i()

RZ_API bool rz_io_write_i ( RzIO io,
ut64  addr,
ut64 val,
int  size,
bool  endian 
)

Definition at line 53 of file ioutils.c.

53  {
54  ut8 buf[8];
55  rz_return_val_if_fail(io && val, false);
56  size = RZ_DIM(size, 1, 8);
57  // size says the number of bytes to read transform to bits for rz_read_ble
58  rz_write_ble(buf, *val, endian, size * 8);
59  return rz_io_write_at(io, addr, buf, size) == size;
60 }
static void rz_write_ble(void *dst, ut64 val, bool big_endian, int size)
Definition: rz_endian.h:548

References addr, RZ_DIM, rz_io_write_at(), rz_return_val_if_fail, rz_write_ble(), and val.

◆ RZ_LIB_VERSION_HEADER()

RZ_LIB_VERSION_HEADER ( rz_io  )

Variable Documentation

◆ rz_io_plugin_ar

RzIOPlugin rz_io_plugin_ar
extern

Definition at line 135 of file io_ar.c.

Referenced by rz_io_ar_open(), and rz_io_ar_open_many().

◆ rz_io_plugin_bfdbg

RzIOPlugin rz_io_plugin_bfdbg
extern

Definition at line 197 of file io_bfdbg.c.

Referenced by __open().

◆ rz_io_plugin_bochs

RzIOPlugin rz_io_plugin_bochs
extern
Initial value:
= {
.name = "bochs",
.desc = "Attach to a BOCHS debugger instance",
.license = "LGPL3",
.uris = "bochs://",
.open = __open,
.close = __close,
.read = __read,
.write = __write,
.check = __plugin_open,
.lseek = __lseek,
.system = __system,
.isdbg = true
}
static int __read(RzIO *io, RzIODesc *fd, ut8 *buf, int count)
Definition: io_bfdbg.c:84
static bool __plugin_open(RzIO *io, const char *pathname, bool many)
Definition: io_bfdbg.c:151
static RzIODesc * __open(RzIO *io, const char *pathname, int rw, int mode)
Definition: io_bfdbg.c:159
static int __write(RzIO *io, RzIODesc *fd, const ut8 *buf, int count)
Definition: io_bfdbg.c:38
static ut64 __lseek(RzIO *io, RzIODesc *fd, ut64 offset, int whence)
Definition: io_bfdbg.c:142
static int __close(RzIODesc *fd)
Definition: io_bfdbg.c:130
static char * __system(RzIO *io, RzIODesc *fd, const char *cmd)
Definition: io_bochs.c:90

Definition at line 106 of file io_bochs.c.

Referenced by __open().

◆ rz_io_plugin_debug

RzIOPlugin rz_io_plugin_debug
extern

Definition at line 571 of file io_debug.c.

◆ rz_io_plugin_default

RzIOPlugin rz_io_plugin_default
extern

Definition at line 200 of file io_default.c.

Referenced by rz_io_def_mmap_open().

◆ rz_io_plugin_dmp

RzIOPlugin rz_io_plugin_dmp
extern

Definition at line 162 of file io_dmp.c.

Referenced by dmp_open().

◆ rz_io_plugin_fd

RzIOPlugin rz_io_plugin_fd
extern

Definition at line 84 of file io_fd.c.

Referenced by __open().

◆ rz_io_plugin_gdb

RzIOPlugin rz_io_plugin_gdb
extern

Definition at line 410 of file io_gdb.c.

Referenced by __open().

◆ rz_io_plugin_gprobe

RzIOPlugin rz_io_plugin_gprobe
extern

Definition at line 1228 of file io_gprobe.c.

Referenced by __open().

◆ rz_io_plugin_gzip

RzIOPlugin rz_io_plugin_gzip
extern

Definition at line 181 of file io_gzip.c.

Referenced by __open().

◆ rz_io_plugin_http

RzIOPlugin rz_io_plugin_http
extern

Definition at line 34 of file io_http.c.

◆ rz_io_plugin_ihex

RzIOPlugin rz_io_plugin_ihex
extern

Definition at line 436 of file io_ihex.c.

Referenced by __open().

◆ rz_io_plugin_mach

RzIOPlugin rz_io_plugin_mach
extern

Definition at line 569 of file io_mach.c.

◆ rz_io_plugin_malloc

RzIOPlugin rz_io_plugin_malloc
extern

Definition at line 50 of file io_malloc.c.

Referenced by __open().

◆ rz_io_plugin_null

RzIOPlugin rz_io_plugin_null
extern

Definition at line 105 of file io_null.c.

Referenced by __open().

◆ rz_io_plugin_procpid

RzIOPlugin rz_io_plugin_procpid
extern

Definition at line 138 of file io_procpid.c.

◆ rz_io_plugin_ptrace

RzIOPlugin rz_io_plugin_ptrace
extern

Definition at line 1 of file io_ptrace.c.

◆ rz_io_plugin_qnx

RzIOPlugin rz_io_plugin_qnx
extern

Definition at line 148 of file io_qnx.c.

Referenced by __open().

◆ rz_io_plugin_rap

RzIOPlugin rz_io_plugin_rap
extern

Definition at line 279 of file io_rap.c.

Referenced by __rap_open().

◆ rz_io_plugin_rzk

RzIOPlugin rz_io_plugin_rzk
extern

Definition at line 137 of file io_rzk.c.

Referenced by rzk__open().

◆ rz_io_plugin_rzpipe

RzIOPlugin rz_io_plugin_rzpipe
extern

Definition at line 177 of file io_rzpipe.c.

Referenced by __open().

◆ rz_io_plugin_rzweb

RzIOPlugin rz_io_plugin_rzweb
extern

Definition at line 156 of file io_rzweb.c.

Referenced by __open().

◆ rz_io_plugin_self

RzIOPlugin rz_io_plugin_self
extern

Definition at line 848 of file io_self.c.

◆ rz_io_plugin_shm

RzIOPlugin rz_io_plugin_shm
extern

Definition at line 267 of file io_shm.c.

◆ rz_io_plugin_sparse

RzIOPlugin rz_io_plugin_sparse
extern

Definition at line 110 of file io_sparse.c.

Referenced by __open().

◆ rz_io_plugin_srec

RzIOPlugin rz_io_plugin_srec
extern

Definition at line 549 of file io_srec.c.

Referenced by __open().

◆ rz_io_plugin_tcp

RzIOPlugin rz_io_plugin_tcp
extern

Definition at line 86 of file io_tcp.c.

Referenced by __open().

◆ rz_io_plugin_w32

RzIOPlugin rz_io_plugin_w32
extern

Definition at line 1 of file io_w32.c.

◆ rz_io_plugin_w32dbg

RzIOPlugin rz_io_plugin_w32dbg
extern

Definition at line 215 of file io_w32dbg.c.

◆ rz_io_plugin_windbg

RzIOPlugin rz_io_plugin_windbg
extern

Definition at line 684 of file io_windbg.c.

Referenced by windbg_open().

◆ rz_io_plugin_winedbg

RzIOPlugin rz_io_plugin_winedbg
extern

Definition at line 366 of file io_winedbg.c.

Referenced by __open().

◆ rz_io_plugin_winkd

RzIOPlugin rz_io_plugin_winkd
extern

Definition at line 148 of file io_winkd.c.

Referenced by __open().

◆ rz_io_plugin_zip

RzIOPlugin rz_io_plugin_zip
extern

Definition at line 675 of file io_zip.c.

Referenced by find_apk_binary(), rz_io_zip_open(), and rz_io_zip_open_many().