Rizin
unix-like reverse engineering framework and cli tools
theory_mem.c File Reference

Go to the source code of this file.

Functions

void * rz_il_handler_load (RzILVM *vm, RzILOpBitVector *op, RzILTypePure *type)
 
bool rz_il_handler_store (RzILVM *vm, RzILOpEffect *op)
 
void * rz_il_handler_loadw (RzILVM *vm, RzILOpBitVector *op, RzILTypePure *type)
 
bool rz_il_handler_storew (RzILVM *vm, RzILOpEffect *op)
 

Function Documentation

◆ rz_il_handler_load()

void* rz_il_handler_load ( RzILVM vm,
RzILOpBitVector op,
RzILTypePure type 
)

Definition at line 8 of file theory_mem.c.

8  {
10  RzILOpArgsLoad *op_load = &op->op.load;
11 
12  RzBitVector *addr = rz_il_evaluate_bitv(vm, op_load->key);
13  if (!addr) {
14  return NULL;
15  }
16  RzBitVector *ret = rz_il_vm_mem_load(vm, op_load->mem, addr);
19  return ret;
20 }
#define NULL
Definition: cris-opc.c:27
RZ_API RZ_NULLABLE RZ_OWN RzBitVector * rz_il_evaluate_bitv(RZ_NONNULL RzILVM *vm, RZ_NONNULL RzILOpBitVector *op)
Definition: il_vm_eval.c:269
RZ_API RzBitVector * rz_il_vm_mem_load(RzILVM *vm, RzILMemIndex index, RzBitVector *key)
Definition: il_vm_eval.c:124
int type
Definition: mipsasm.c:17
#define rz_return_val_if_fail(expr, val)
Definition: rz_assert.h:108
RZ_API void rz_bv_free(RZ_NULLABLE RzBitVector *bv)
Definition: bitvector.c:85
@ RZ_IL_TYPE_PURE_BITVECTOR
Definition: sort.h:25
structure for bitvector
Definition: rz_bitvector.h:19
op structure for load (('a, 'b) mem -> 'a bitv -> 'b bitv)
RzILMemIndex mem
index of the mem inside the vm to use
RzILOpBitVector * key
index of the cell (address) in mem, must have exactly the size of a key in the memory
Definition: dis.c:32
static int addr
Definition: z80asm.c:58

References addr, rz_il_op_args_load_t::key, rz_il_op_args_load_t::mem, NULL, rz_bv_free(), rz_il_evaluate_bitv(), RZ_IL_TYPE_PURE_BITVECTOR, rz_il_vm_mem_load(), rz_return_val_if_fail, and type.

◆ rz_il_handler_loadw()

void* rz_il_handler_loadw ( RzILVM vm,
RzILOpBitVector op,
RzILTypePure type 
)

Definition at line 41 of file theory_mem.c.

41  {
42  rz_return_val_if_fail(vm && op && type, NULL);
43  RzILOpArgsLoadW *op_loadw = &op->op.loadw;
44 
45  RzBitVector *addr = rz_il_evaluate_bitv(vm, op_loadw->key);
46  if (!addr) {
47  return NULL;
48  }
49  RzBitVector *ret = rz_il_vm_mem_loadw(vm, op_loadw->mem, addr, op_loadw->n_bits);
52  return ret;
53 }
RZ_API RzBitVector * rz_il_vm_mem_loadw(RzILVM *vm, RzILMemIndex index, RzBitVector *key, ut32 n_bits)
Definition: il_vm_eval.c:163
Load an entire word of arbitrary bit size from a memory.
RzILOpBitVector * key
memory index of the RzBitVector key (address)
RzILMemIndex mem
index of the mem inside the vm to use
ut32 n_bits
n of bits to read, and of the resulting bitvector

References addr, rz_il_op_args_loadw_t::key, rz_il_op_args_loadw_t::mem, rz_il_op_args_loadw_t::n_bits, NULL, rz_bv_free(), rz_il_evaluate_bitv(), RZ_IL_TYPE_PURE_BITVECTOR, rz_il_vm_mem_loadw(), rz_return_val_if_fail, and type.

◆ rz_il_handler_store()

bool rz_il_handler_store ( RzILVM vm,
RzILOpEffect op 
)

Definition at line 22 of file theory_mem.c.

22  {
24 
25  RzILOpArgsStore *op_store = &op->op.store;
26 
27  RzBitVector *addr = rz_il_evaluate_bitv(vm, op_store->key);
28  RzBitVector *value = rz_il_evaluate_bitv(vm, op_store->value);
29 
30  bool ret = false;
31  if (addr && value) {
32  ret = true;
33  rz_il_vm_mem_store(vm, op_store->mem, addr, value);
34  }
37 
38  return ret;
39 }
static int value
Definition: cmd_api.c:93
RZ_API void rz_il_vm_mem_store(RzILVM *vm, RzILMemIndex index, RzBitVector *key, RzBitVector *value)
Definition: il_vm_eval.c:144
op structure for store (('a, 'b) mem -> 'a bitv -> 'b bitv -> ('a, 'b) mem)
RzILOpBitVector * value
value to store, must have exactly the size of a memory cell
RzILOpBitVector * key
address where to store to, must have exactly the size of a key in the memory
RzILMemIndex mem
index of memory in the vm to use

References addr, rz_il_op_args_store_t::key, rz_il_op_args_store_t::mem, NULL, rz_bv_free(), rz_il_evaluate_bitv(), rz_il_vm_mem_store(), rz_return_val_if_fail, value, and rz_il_op_args_store_t::value.

◆ rz_il_handler_storew()

bool rz_il_handler_storew ( RzILVM vm,
RzILOpEffect op 
)

Definition at line 55 of file theory_mem.c.

55  {
57 
58  RzILOpArgsStoreW *op_storew = &op->op.storew;
59 
60  RzBitVector *addr = rz_il_evaluate_bitv(vm, op_storew->key);
61  RzBitVector *value = rz_il_evaluate_bitv(vm, op_storew->value);
62 
63  bool ret = false;
64  if (addr && value) {
65  ret = true;
66  rz_il_vm_mem_storew(vm, op_storew->mem, addr, value);
67  }
68 
71 
72  return ret;
73 }
RZ_API void rz_il_vm_mem_storew(RzILVM *vm, RzILMemIndex index, RzBitVector *key, RzBitVector *value)
Definition: il_vm_eval.c:183
Store an entire word of arbitrary bit size into a memory.
RzILOpBitVector * value
value to store, arbitrary size
RzILMemIndex mem
index of memory in the vm to use
RzILOpBitVector * key
address where to store to

References addr, rz_il_op_args_storew_t::key, rz_il_op_args_storew_t::mem, NULL, rz_bv_free(), rz_il_evaluate_bitv(), rz_il_vm_mem_storew(), rz_return_val_if_fail, value, and rz_il_op_args_storew_t::value.