73 core->analysis->esil =
NULL;
79 const ut64 bs = 4096 * 32;
81 for (
i = 0;
i <
size;
i += bs) {
93 eprintf(
"Couldn't generate pattern of length %" PFMT64d "\n", left);
119 const ut64 align = 0x10000000;
151 ut64 current_offset = core->offset;
155 eprintf(
"Cannot initialize ESIL\n");
167 const char *pattern =
rz_config_get(core->config,
"esil.stack.pattern");
175 eprintf(
"Cannot create map for tha stack, fd %d got closed again\n", esil->
stack_fd);
184 sdb_set(core->sdb,
"aeim.fd",
v, 0);
187 if (pattern && *pattern) {
251 eprintf(
"Cannot deinitialize %s\n", stack_name);
273 until_addr =
op->addr +
op->size;
312 const int minopcode =
RZ_MAX(1, mininstrsz);
319 eprintf(
"Warning: cmd_espc: creating new esil instance\n");
327 eprintf(
"Cannot allocate %d byte(s)\n", bsize);
337 for (
i = 0, j = 0; j <
off;
i++, j++) {
341 if (
i >= (bsize - 32)) {
348 if (
addr == until_addr) {
422 eprintf(
"Assert: analysis.from > analysis.to\n");
456 RZ_LOG_ERROR(
"RzIL: Run 'aezi' first to initialize the VM\n");
460 if (!strcmp(var_name,
"PC")) {
491 #define p_sb(x) ((RzStrBuf *)x)
492 #define p_tbl(x) ((RzTable *)x)
493 #define p_pj(x) ((PJ *)x)
534 RZ_LOG_ERROR(
"RzIL: Run 'aezi' first to initialize the VM\n");
557 if (!var_name || !strcmp(var_name,
"PC")) {
567 if (var_name && strcmp(var_name, var->
name)) {
632 RZ_LOG_ERROR(
"RzIL: Run 'aezi' first to initialize the VM\n");
641 RZ_LOG_ERROR(
"RzIL: invalid instruction or lifting not implemented at address 0x%08" PFMT64x "\n",
673 if (!evt_read && !evt_write) {
674 RZ_LOG_ERROR(
"RzIL: cannot print events when all the events are disabled.");
675 RZ_LOG_ERROR(
"RzIL: please set 'rzil.step.events.read' or/and 'rzil.step.events.write' to true and try again.");
682 rz_list_foreach (vm->
events, it, evt) {
RZ_API ut64 rz_analysis_function_max_addr(RzAnalysisFunction *fcn)
RZ_API ut64 rz_analysis_function_min_addr(RzAnalysisFunction *fcn)
RZ_API int rz_analysis_archinfo(RzAnalysis *analysis, int query)
RZ_API bool rz_analysis_il_vm_setup(RzAnalysis *analysis)
RZ_API RzAnalysisILStepResult rz_analysis_il_vm_step(RZ_NONNULL RzAnalysis *analysis, RZ_NONNULL RzAnalysisILVM *vm, RZ_NULLABLE RzReg *reg)
RZ_API RzAnalysisBlock * rz_analysis_find_most_relevant_block_in(RzAnalysis *analysis, ut64 off)
const lzma_allocator const uint8_t size_t uint8_t * out
RZ_API RzILBool * rz_il_bool_new(bool true_or_false)
static RzNumCalcValue expr(RzNum *, RzNumCalc *, int)
RZ_API RzAnalysisOp * rz_core_analysis_op(RzCore *core, ut64 addr, int mask)
RZ_API void rz_core_analysis_esil(RzCore *core, ut64 addr, ut64 size, RZ_NULLABLE RzAnalysisFunction *fcn)
RZ_IPI void rz_core_analysis_esil_emulate(RzCore *core, ut64 addr, ut64 until_addr, int off)
RZ_IPI void rz_core_analysis_esil_init_mem_p(RzCore *core)
RZ_IPI void rz_core_analysis_esil_emulate_bb(RzCore *core)
struct il_print_t ILPrint
RZ_IPI bool rz_core_analysis_il_vm_set(RzCore *core, const char *var_name, ut64 value)
Set a vm variable from user input.
RZ_IPI void rz_core_analysis_esil_references_all_functions(RzCore *core)
static void rzil_print_register_bitv(RzBitVector *number, ILPrint *p)
RZ_API void rz_core_analysis_esil_init_mem(RZ_NONNULL RzCore *core, RZ_NULLABLE const char *name, ut64 addr, ut32 size)
RZ_IPI void rz_core_analysis_esil_default(RzCore *core)
static void initialize_stack(RzCore *core, ut64 addr, ut64 size)
RZ_IPI bool rz_core_analysis_il_step_with_events(RzCore *core, PJ *pj)
RZ_API void rz_core_analysis_esil_init_regs(RZ_NONNULL RzCore *core)
static void rzil_print_register_bool(bool value, ILPrint *p)
static void core_esil_init(RzCore *core)
RZ_IPI void rz_core_analysis_esil_init(RzCore *core)
RZ_IPI void rz_core_analysis_esil_step_over_until(RzCore *core, ut64 addr)
RZ_IPI bool rz_core_il_step(RzCore *core)
RZ_IPI void rz_core_analysis_il_vm_status(RzCore *core, const char *var_name, RzOutputMode mode)
RZ_IPI int rz_core_analysis_set_reg(RzCore *core, const char *regname, ut64 val)
RZ_API void rz_core_analysis_esil_step_over(RZ_NONNULL RzCore *core)
RZ_API void rz_core_analysis_esil_reinit(RZ_NONNULL RzCore *core)
Reinitialize ESIL.
static char * get_esil_stack_name(RzCore *core, const char *name, ut64 *addr, ut32 *size)
RZ_API void rz_core_analysis_esil_deinit(RZ_NONNULL RzCore *core)
Deinitialize ESIL.
RZ_IPI void rz_core_analysis_esil_step_over_untilexpr(RzCore *core, const char *expr)
RZ_API void rz_core_analysis_esil_init_mem_del(RZ_NONNULL RzCore *core, RZ_NULLABLE const char *name, ut64 addr, ut32 size)
Remove ESIL VM stack.
RZ_IPI void rz_core_analysis_il_reinit(RzCore *core)
RZ_API bool rz_core_write_at(RzCore *core, ut64 addr, const ut8 *buf, int size)
RZ_API int rz_core_cmdf(RzCore *core, const char *fmt,...)
RZ_API int rz_core_esil_step(RzCore *core, ut64 until_addr, const char *until_expr, ut64 *prev_addr, bool stepOver)
RZ_API RZ_OWN RzList * rz_core_get_boundaries_prot(RzCore *core, int perm, const char *mode, const char *prefix)
RZ_API ut64 rz_config_get_i(RzConfig *cfg, RZ_NONNULL const char *name)
RZ_API bool rz_config_get_b(RzConfig *cfg, RZ_NONNULL const char *name)
RZ_API RzConfigNode * rz_config_set(RzConfig *cfg, RZ_NONNULL const char *name, const char *value)
RZ_API RZ_BORROW const char * rz_config_get(RzConfig *cfg, RZ_NONNULL const char *name)
RZ_API RzConfigNode * rz_config_set_b(RzConfig *cfg, RZ_NONNULL const char *name, bool value)
RZ_API int rz_cons_printf(const char *format,...)
RZ_API bool rz_cons_is_breaked(void)
RZ_API void rz_core_reg_update_flags(RzCore *core)
Update or create flags for all registers where it makes sense.
size_t map(int syms, int left, int len)
RZ_API RzAnalysisEsil * rz_analysis_esil_new(int stacksize, int iotrap, unsigned int addrsize)
RZ_API bool rz_analysis_esil_setup(RzAnalysisEsil *esil, RzAnalysis *analysis, int romem, int stats, int nonull)
RZ_API bool rz_analysis_esil_parse(RzAnalysisEsil *esil, const char *str)
RZ_API void rz_analysis_esil_free(RzAnalysisEsil *esil)
RZ_API RzFlagItem * rz_flag_get(RzFlag *f, const char *name)
RZ_API bool rz_flag_unset_name(RzFlag *f, const char *name)
RZ_API void Ht_() free(HtName_(Ht) *ht)
RZ_API RZ_OWN RzILVal * rz_il_value_new_bitv(RZ_NONNULL RzBitVector *bv)
RZ_API RZ_OWN RzILVal * rz_il_value_new_bool(RZ_NONNULL RzILBool *b)
RZ_API void rz_il_event_json(RZ_NONNULL RzILEvent *evt, RZ_NONNULL PJ *pj)
RZ_API void rz_il_event_stringify(RZ_NONNULL const RzILEvent *evt, RZ_NONNULL RzStrBuf *sb)
RZ_API void rz_il_vm_set_global_var(RZ_NONNULL RzILVM *vm, RZ_NONNULL const char *name, RZ_OWN RzILVal *val)
RZ_API RZ_OWN RzPVector * rz_il_vm_get_all_vars(RZ_NONNULL RzILVM *vm, RzILVarKind kind)
RZ_API RZ_BORROW RzILVal * rz_il_vm_get_var_value(RZ_NONNULL RzILVM *vm, RzILVarKind kind, const char *name)
RZ_API RZ_BORROW RzILVar * rz_il_vm_get_var(RZ_NONNULL RzILVM *vm, RzILVarKind kind, const char *name)
static void list(RzEgg *egg)
RZ_API void rz_list_free(RZ_NONNULL RzList *list)
Empties the list and frees the list pointer.
void * malloc(size_t size)
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 void rz_analysis_op_free(void *op)
RZ_API bool rz_analysis_op_fini(RzAnalysisOp *op)
RZ_API int rz_analysis_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *data, int len, RzAnalysisOpMask mask)
static const char hex[16]
RZ_API ut64 rz_reg_getv(RzReg *reg, const char *name)
RZ_API RzRegItem * rz_reg_get(RzReg *reg, const char *name, int type)
RZ_API const char * rz_reg_get_name(RzReg *reg, int role)
RZ_API int rz_reg_get_name_idx(const char *type)
RZ_API ut64 rz_reg_setv(RzReg *reg, const char *name, ut64 val)
RZ_API bool rz_reg_set_value_by_role(RzReg *reg, RzRegisterId role, ut64 val)
RZ_API ut64 rz_reg_get_value_by_role(RzReg *reg, RzRegisterId role)
RZ_API bool rz_reg_set_value(RzReg *reg, RzRegItem *item, ut64 value)
@ RZ_ANALYSIS_IL_STEP_INVALID_OP
@ RZ_ANALYSIS_IL_STEP_RESULT_SUCCESS
@ RZ_ANALYSIS_OP_MASK_DISASM
@ RZ_ANALYSIS_OP_MASK_BASIC
@ RZ_ANALYSIS_OP_MASK_ESIL
@ RZ_ANALYSIS_OP_MASK_HINT
#define RZ_ANALYSIS_ARCHINFO_MIN_OP_SIZE
@ RZ_ANALYSIS_OP_TYPE_CALL
#define rz_warn_if_reached()
#define rz_return_if_fail(expr)
#define rz_return_val_if_fail(expr, val)
RZ_API void rz_bv_free(RZ_NULLABLE RzBitVector *bv)
RZ_API RZ_OWN RzBitVector * rz_bv_new_from_ut64(ut32 length, ut64 value)
RZ_API RZ_OWN char * rz_bv_as_hex_string(RZ_NONNULL RzBitVector *bv, bool pad)
RZ_API RZ_OWN char * rz_debruijn_pattern(int size, int start, const char *charset)
Generate a cyclic pattern following the Debruijn pattern.
RZ_API bool rz_io_read_at(RzIO *io, ut64 addr, ut8 *buf, int len)
RZ_API int rz_io_fd_open(RzIO *io, const char *uri, int flags, int mode)
RZ_API ut64 rz_io_map_next_available(RzIO *io, ut64 addr, ut64 size, ut64 load_align)
RZ_API RzIOMap * rz_io_map_get(RzIO *io, ut64 addr)
RZ_API void rz_io_map_set_name(RzIOMap *map, const char *name)
RZ_API RzIOMap * rz_io_map_add(RzIO *io, int fd, int flags, ut64 delta, ut64 addr, ut64 size)
RZ_API bool rz_io_fd_close(RzIO *io, int fd)
#define RZ_LOG_ERROR(fmtstr,...)
RZ_API PJ * pj_kb(PJ *j, const char *k, bool v)
RZ_API char * pj_drain(PJ *j)
RZ_API PJ * pj_end(PJ *j)
RZ_API PJ * pj_ks(PJ *j, const char *k, const char *v)
RZ_API char * rz_str_newf(const char *fmt,...) RZ_PRINTF_CHECK(1
RZ_API const char * rz_str_bool(int b)
#define RZ_STR_ISEMPTY(x)
#define rz_strf(buf,...)
Convenience macro for local temporary strings.
RZ_API RZ_OWN char * rz_strbuf_drain(RzStrBuf *sb)
#define RZ_STRBUF_SAFEGET(sb)
RZ_API char * rz_strbuf_get(RzStrBuf *sb)
RZ_API bool rz_strbuf_append(RzStrBuf *sb, const char *s)
RZ_API void rz_strbuf_fini(RzStrBuf *sb)
RZ_API RzStrBuf * rz_strbuf_new(const char *s)
RZ_API void rz_strbuf_free(RzStrBuf *sb)
RZ_API bool rz_strbuf_appendf(RzStrBuf *sb, const char *fmt,...) RZ_PRINTF_CHECK(2
RZ_API int rz_strbuf_length(RzStrBuf *sb)
RZ_API void rz_table_add_rowf(RzTable *t, const char *fmt,...)
RZ_API void rz_table_free(RzTable *t)
RZ_API void rz_table_set_columnsf(RzTable *t, const char *fmt,...)
Specify the types and names of the referenced table.
RZ_API char * rz_table_tostring(RzTable *t)
RZ_API RzTable * rz_table_new(void)
RzOutputMode
Enum to describe the way data are printed.
@ RZ_OUTPUT_MODE_STANDARD
RZ_API void rz_pvector_free(RzPVector *vec)
#define rz_pvector_foreach(vec, it)
RZ_API int sdb_set(Sdb *s, const char *key, const char *val, ut32 cas)
RZ_API void sdb_reset(Sdb *s)
RZ_API const char * sdb_const_get(Sdb *s, const char *key, ut32 *cas)
RZ_API int sdb_unset(Sdb *s, const char *key, ut32 cas)
RZ_API char * sdb_itoa(ut64 n, char *s, int base)
RZ_API ut64 sdb_atoi(const char *s)
RZ_API bool rz_core_seek(RzCore *core, ut64 addr, bool rb)
Seek to addr.
static struct sockaddr static addrlen static backlog const void static flags void struct sockaddr from
static struct sockaddr static addrlen static backlog const void static flags void struct sockaddr socklen_t static fromlen const void const struct sockaddr to
static struct sockaddr static addrlen static backlog const void static flags void flags
@ RZ_IL_TYPE_PURE_BITVECTOR
ut32 len
number of bits – virtual / logical
High-level RzIL vm to emulate disassembled code.
RZ_NONNULL RzILVM * vm
low-level vm to execute IL code
struct rz_analysis_esil_t * esil
RzAnalysisILVM * il_vm
user-faced VM, NEVER use this for any analysis passes!
struct rz_il_sort_pure_t::@283::@284 bv
union rz_il_sort_pure_t::@283 props
Definition of a variable inside the vm.
RzILSortPure sort
"type" of the variable
Low-level VM to execute raw IL code.
RzList * events
List of events that has happened in the last step.
RzBitVector * pc
Program Counter of VM.
@ RZ_IL_VAR_KIND_GLOBAL
global var, usually bound to a physical representation like a register.
if(dbg->bits==RZ_SYS_BITS_64)
ut64(WINAPI *w32_GetEnabledXStateFeatures)()
static char * regname(int reg)
static const z80_opcode fd[]