Rizin
unix-like reverse engineering framework and cli tools
theory_mem.c
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2021 Florian Märkl <info@florianmaerkl.de>
2 // SPDX-FileCopyrightText: 2021 heersin <teablearcher@gmail.com>
3 // SPDX-License-Identifier: LGPL-3.0-only
4 
5 #include <rz_il/rz_il_vm.h>
6 #include <rz_il/rz_il_opcodes.h>
7 
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 }
21 
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 }
40 
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 }
54 
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 }
static int value
Definition: cmd_api.c:93
#define NULL
Definition: cris-opc.c:27
RZ_API void rz_il_vm_mem_storew(RzILVM *vm, RzILMemIndex index, RzBitVector *key, RzBitVector *value)
Definition: il_vm_eval.c:183
RZ_API void rz_il_vm_mem_store(RzILVM *vm, RzILMemIndex index, RzBitVector *key, RzBitVector *value)
Definition: il_vm_eval.c:144
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
RZ_API RzBitVector * rz_il_vm_mem_loadw(RzILVM *vm, RzILMemIndex index, RzBitVector *key, ut32 n_bits)
Definition: il_vm_eval.c:163
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
signatures of core theory opcodes
RzILTypePure
Definition: sort.h:23
@ 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
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
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
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
An IL op performing a pure computation, 'a pure.
Low-level VM to execute raw IL code.
Definition: rz_il_vm.h:37
void * rz_il_handler_loadw(RzILVM *vm, RzILOpBitVector *op, RzILTypePure *type)
Definition: theory_mem.c:41
void * rz_il_handler_load(RzILVM *vm, RzILOpBitVector *op, RzILTypePure *type)
Definition: theory_mem.c:8
bool rz_il_handler_storew(RzILVM *vm, RzILOpEffect *op)
Definition: theory_mem.c:55
bool rz_il_handler_store(RzILVM *vm, RzILOpEffect *op)
Definition: theory_mem.c:22
Definition: dis.c:32
static int addr
Definition: z80asm.c:58