Rizin
unix-like reverse engineering framework and cli tools
ioutils.c File Reference
#include <rz_io.h>
#include <rz_util.h>
#include <rz_types.h>
#include "io_private.h"

Go to the source code of this file.

Functions

RZ_API bool rz_io_addr_is_mapped (RzIO *io, ut64 vaddr)
 
RZ_API bool rz_io_is_valid_offset (RzIO *io, ut64 offset, int hasperm)
 
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)
 

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_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 }
size_t map(int syms, int left, int len)
Definition: enough.c:237
voidpf uLong offset
Definition: ioapi.h:144
RZ_API ut64 rz_io_desc_size(RzIODesc *desc)
Definition: io_desc.c:224
#define RZ_PERM_R
Definition: rz_types.h:93
int perm
Definition: rz_io.h:97
struct rz_io_desc_t * desc
Definition: rz_io.h:60

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_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
voidpf void uLong size
Definition: ioapi.h:138
voidpf void * buf
Definition: ioapi.h:138
uint8_t ut8
Definition: lh5801.h:11
static ut64 rz_read_ble(const void *src, bool big_endian, int size)
Definition: rz_endian.h:517
RZ_API bool rz_io_read_at(RzIO *io, ut64 addr, ut8 *buf, int len)
Definition: io.c:300
#define RZ_DIM(x, y, z)
static int addr
Definition: z80asm.c:58

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_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
RZ_API bool rz_io_write_at(RzIO *io, ut64 addr, const ut8 *buf, int len)
Definition: io.c:358

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