|
Rizin
unix-like reverse engineering framework and cli tools
|
#include <rz_il/rz_il_vm.h>Go to the source code of this file.
Variables | |
| RZ_IPI RzILOpPureHandler | rz_il_op_handler_pure_table_default [RZ_IL_OP_PURE_MAX] |
| RZ_IPI RzILOpEffectHandler | rz_il_op_handler_effect_table_default [RZ_IL_OP_EFFECT_MAX] |
RzIL Virtual Machine Setup and Management For the actual evaluation (emulation), see il_vm_eval.c
Definition in file il_vm.c.
|
static |
Definition at line 16 of file il_vm.c.
References free(), and rz_il_effect_label_free().
Referenced by rz_il_vm_init().
| RZ_API RZ_BORROW RzBitVector* rz_il_hash_find_addr_by_lblname | ( | RZ_NONNULL RzILVM * | vm, |
| RZ_NONNULL const char * | lbl_name | ||
| ) |
Find the bitvector address by given name
| vm | RzILVM* vm, pointer to VM |
| lbl_name | string, the name of label |
Definition at line 275 of file il_vm.c.
References found, NULL, and rz_return_val_if_fail.
| RZ_API void rz_il_vm_add_label | ( | RZ_NONNULL RzILVM * | vm, |
| RZ_NONNULL RzILEffectLabel * | label | ||
| ) |
Definition at line 296 of file il_vm.c.
References rz_return_if_fail.
Referenced by rz_il_vm_create_label(), rz_il_vm_create_label_lazy(), and setup_vm_from_config().
| RZ_API void rz_il_vm_add_mem | ( | RzILVM * | vm, |
| RzILMemIndex | index, | ||
| RZ_OWN RzILMem * | mem | ||
| ) |
Add a memory to VM at the given index. Ownership of the memory is transferred to the VM.
Definition at line 153 of file il_vm.c.
References mem, NULL, rz_mem_free(), rz_pvector_at(), rz_pvector_len(), rz_pvector_push(), rz_pvector_reserve(), rz_pvector_set(), and rz_il_vm_t::vm_memory.
Referenced by setup_vm_from_config().
| RZ_API RZ_BORROW RzILVar* rz_il_vm_create_global_var | ( | RZ_NONNULL RzILVM * | vm, |
| RZ_NONNULL const char * | name, | ||
| RzILSortPure | sort | ||
| ) |
Create a new global variable of the given sort and assign it to all-zero/false
Definition at line 175 of file il_vm.c.
References NULL, rz_il_value_new_zero_of(), rz_il_var_set_bind(), rz_il_var_set_create_var(), rz_return_val_if_fail, and val.
Referenced by rz_il_vm_setup_reg_binding().
| RZ_API RZ_BORROW RzILEffectLabel* rz_il_vm_create_label | ( | RZ_NONNULL RzILVM * | vm, |
| RZ_NONNULL const char * | name, | ||
| RZ_NONNULL RZ_BORROW RzBitVector * | addr | ||
| ) |
Create a label in VM
| vm | RzILVM, pointer to VM |
| name | string, name of label |
| addr | RzBitVector, label address |
Definition at line 308 of file il_vm.c.
References addr, rz_il_effect_label_t::addr, EFFECT_LABEL_ADDR, NULL, rz_bv_dup(), rz_il_effect_label_new(), rz_il_vm_add_label(), and rz_return_val_if_fail.
Referenced by rz_il_handler_blk().
| RZ_API RZ_BORROW RzILEffectLabel* rz_il_vm_create_label_lazy | ( | RZ_NONNULL RzILVM * | vm, |
| RZ_NONNULL const char * | name | ||
| ) |
Create a label without address, use rz_il_vm_update_label to update address for it
| vm | RzILVM, pointer to VM |
| name | string, name of this label |
Definition at line 322 of file il_vm.c.
References rz_il_effect_label_t::addr, EFFECT_LABEL_ADDR, NULL, rz_il_effect_label_new(), rz_il_vm_add_label(), and rz_return_val_if_fail.
| RZ_API RZ_BORROW RzILEffectLabel* rz_il_vm_find_label_by_name | ( | RZ_NONNULL RzILVM * | vm, |
| RZ_NONNULL const char * | lbl_name | ||
| ) |
Find the label instance by name
| vm | RzILVM, pointer to VM |
| lbl_name | string, the name of label |
Definition at line 291 of file il_vm.c.
References NULL, and rz_return_val_if_fail.
Referenced by rz_il_handler_goto().
Close and clean vm
| vm | RzILVM* pointer to VM |
Definition at line 93 of file il_vm.c.
References rz_il_vm_t::events, free(), rz_il_vm_t::global_vars, rz_il_vm_t::local_pure_vars, rz_il_vm_t::local_vars, NULL, rz_il_vm_t::op_handler_effect_table, rz_il_vm_t::op_handler_pure_table, rz_il_vm_t::pc, rz_bv_free(), rz_il_var_set_fini(), rz_list_free(), rz_pvector_fini(), rz_il_vm_t::vm_global_label_table, and rz_il_vm_t::vm_memory.
Referenced by rz_il_vm_free(), and rz_il_vm_init().
Close, clean and free vm
| vm | RzILVM* pointer to VM |
Definition at line 134 of file il_vm.c.
References free(), and rz_il_vm_fini().
Referenced by rz_analysis_il_vm_free(), and setup_vm_from_config().
| RZ_API RZ_OWN RzPVector* rz_il_vm_get_all_vars | ( | RZ_NONNULL RzILVM * | vm, |
| RzILVarKind | kind | ||
| ) |
Definition at line 256 of file il_vm.c.
References NULL, rz_il_var_set_get_all(), rz_return_val_if_fail, and var_set_of_kind().
Referenced by rz_core_analysis_il_vm_status(), and rz_il_validate_global_context_new_from_vm().
| RZ_API RzILMem* rz_il_vm_get_mem | ( | RzILVM * | vm, |
| RzILMemIndex | index | ||
| ) |
Definition at line 165 of file il_vm.c.
References NULL, rz_pvector_at(), rz_pvector_len(), and rz_il_vm_t::vm_memory.
Referenced by rz_il_vm_mem_load(), rz_il_vm_mem_loadw(), rz_il_vm_mem_store(), and rz_il_vm_mem_storew().
Get the number of bits of the program counter bitvector
Definition at line 145 of file il_vm.c.
References rz_il_vm_t::pc, and rz_bv_len().
Referenced by rz_il_validate_global_context_new_from_vm().
| RZ_API RZ_BORROW RzILVar* rz_il_vm_get_var | ( | RZ_NONNULL RzILVM * | vm, |
| RzILVarKind | kind, | ||
| const char * | name | ||
| ) |
Definition at line 251 of file il_vm.c.
References NULL, rz_il_var_set_get(), rz_return_val_if_fail, and var_set_of_kind().
Referenced by rz_core_analysis_il_vm_set(), rz_il_set(), and rz_il_vm_sync_from_reg().
| RZ_API RZ_BORROW RzILVal* rz_il_vm_get_var_value | ( | RZ_NONNULL RzILVM * | vm, |
| RzILVarKind | kind, | ||
| const char * | name | ||
| ) |
Get the current value of the variable identified by its name and kind.
Definition at line 264 of file il_vm.c.
References NULL, rz_il_var_set_get_value(), rz_return_val_if_fail, and var_set_of_kind().
Referenced by bf_syscall_read(), bf_syscall_write(), il_event_new_write_from_var(), rz_core_analysis_il_vm_status(), rz_il_handler_var(), and rz_il_vm_sync_to_reg().
initiate an empty VM
| vm | RzILVM, pointer to an empty VM |
| start_addr | ut64, initiation pc address |
| addr_size | ut32, size of the address in VM |
Definition at line 27 of file il_vm.c.
References rz_il_vm_t::addr_size, rz_il_vm_t::big_endian, rz_il_vm_t::events, free_label_kv(), rz_il_vm_t::global_vars, rz_il_vm_t::lab_count, rz_il_vm_t::local_pure_vars, rz_il_vm_t::local_vars, memcpy(), NULL, rz_il_vm_t::op_handler_effect_table, rz_il_vm_t::op_handler_pure_table, rz_il_vm_t::pc, rz_bv_new_from_ut64(), rz_il_event_free(), rz_il_mem_free(), RZ_IL_OP_EFFECT_MAX, rz_il_op_handler_effect_table_default, rz_il_op_handler_pure_table_default, RZ_IL_OP_PURE_MAX, rz_il_var_set_init(), rz_il_vm_fini(), rz_list_newf(), RZ_LOG_ERROR, RZ_NEWS0, rz_pvector_init(), rz_return_val_if_fail, sdb_hash(), strdup(), rz_il_vm_t::val_count, rz_il_vm_t::vm_global_label_table, and rz_il_vm_t::vm_memory.
Referenced by rz_il_vm_new().
Create a new empty VM
| vm | RzILVM, pointer to an empty VM |
| start_addr | ut64, initiation pc address |
| addr_size | ut32, size of the address in VM |
Definition at line 121 of file il_vm.c.
References NULL, rz_il_vm_init(), and RZ_NEW0.
Referenced by setup_vm_from_config().
| RZ_API void rz_il_vm_pop_local_pure_var | ( | RZ_NONNULL RzILVM * | vm, |
| RZ_NONNULL const char * | name, | ||
| RzILLocalPurePrev | prev | ||
| ) |
Remove a local let binding and restore the state for the outer context.
| prev | pass here the return value of rz_il_vm_push_local_pure_var() |
Definition at line 227 of file il_vm.c.
References r, rz_il_value_free(), rz_il_value_get_sort(), rz_il_var_set_bind(), rz_il_var_set_create_var(), rz_il_var_set_remove_var(), rz_return_if_fail, and rz_warn_if_fail.
Referenced by rz_il_handler_let().
| RZ_API RzILLocalPurePrev rz_il_vm_push_local_pure_var | ( | RZ_NONNULL RzILVM * | vm, |
| RZ_NONNULL const char * | name, | ||
| RzILVal * | val | ||
| ) |
Create and assign a new local let binding.
This is meant to be called right before evaluating the body of a let expression. Inside the body, name will then be bound to val. Because there might already exist an outer binding of the same name shadowing this one, the previous value is returned. After evaluating the body, call rz_il_vm_pop_local_pure_var(), passing this value.
Definition at line 215 of file il_vm.c.
References NULL, r, rz_il_value_get_sort(), rz_il_var_set_bind(), rz_il_var_set_create_var(), rz_il_var_set_remove_var(), rz_return_val_if_fail, and val.
Referenced by rz_il_handler_let().
| RZ_API void rz_il_vm_set_global_var | ( | RZ_NONNULL RzILVM * | vm, |
| RZ_NONNULL const char * | name, | ||
| RZ_OWN RzILVal * | val | ||
| ) |
Set the value of a global variable to the given value. The variable must already exist.
Definition at line 193 of file il_vm.c.
References rz_il_var_set_bind(), rz_return_if_fail, and val.
Referenced by rz_core_analysis_il_vm_set(), rz_il_set(), rz_il_vm_sync_from_reg(), and setup_vm_init_state().
| RZ_API void rz_il_vm_set_local_var | ( | RZ_NONNULL RzILVM * | vm, |
| RZ_NONNULL const char * | name, | ||
| RZ_OWN RzILVal * | val | ||
| ) |
Set the value of a local variable to the given value. The variable is created with the sort of val if it does not already exist.
Definition at line 202 of file il_vm.c.
References rz_il_value_get_sort(), rz_il_var_set_bind(), rz_il_var_set_create_var(), rz_return_if_fail, and val.
Referenced by rz_il_set().
| RZ_API RZ_BORROW RzILEffectLabel* rz_il_vm_update_label | ( | RZ_NONNULL RzILVM * | vm, |
| RZ_NONNULL char * | name, | ||
| RZ_NONNULL RZ_BORROW RzBitVector * | addr | ||
| ) |
Update the address info of a label
| vm | RzILVM, pointer to VM |
| name | string, name of this label |
Definition at line 336 of file il_vm.c.
References addr, rz_il_effect_label_t::addr, NULL, rz_bv_dup(), rz_bv_free(), and rz_return_val_if_fail.
|
static |
Definition at line 238 of file il_vm.c.
References rz_il_vm_t::global_vars, rz_il_vm_t::local_pure_vars, rz_il_vm_t::local_vars, NULL, RZ_IL_VAR_KIND_GLOBAL, RZ_IL_VAR_KIND_LOCAL, RZ_IL_VAR_KIND_LOCAL_PURE, and rz_warn_if_reached.
Referenced by rz_il_vm_get_all_vars(), rz_il_vm_get_var(), and rz_il_vm_get_var_value().
|
extern |
Definition at line 104 of file il_vm_eval.c.
Referenced by rz_il_vm_init().
|
extern |
Definition at line 67 of file il_vm_eval.c.
Referenced by rz_il_vm_init().