Rizin
unix-like reverse engineering framework and cli tools
|
#include <rz_analysis.h>
#include <rz_parse.h>
#include <rz_util.h>
#include <rz_list.h>
#include <rz_types_overflow.h>
Go to the source code of this file.
Macros | |
#define | aprintf(format, ...) RZ_LOG_DEBUG(format, __VA_ARGS__) |
Functions | |
static void | apply_case (RzAnalysis *analysis, RzAnalysisBlock *block, ut64 switch_addr, ut64 offset_sz, ut64 case_addr, ut64 id, ut64 case_addr_loc) |
static void | apply_switch (RzAnalysis *analysis, ut64 switch_addr, ut64 jmptbl_addr, ut64 cases_count, ut64 default_case_addr) |
RZ_API bool | rz_analysis_jmptbl (RzAnalysis *analysis, RzAnalysisFunction *fcn, RzAnalysisBlock *block, ut64 jmpaddr, ut64 table, ut64 tablesize, ut64 default_addr) |
static bool | jmptable_size_is_invalid (RzAnalysisJmpTableParams *params) |
RZ_API bool | rz_analysis_walkthrough_casetbl (RZ_NONNULL RzAnalysis *analysis, RZ_NONNULL RzAnalysisFunction *fcn, RZ_NONNULL RzAnalysisBlock *block, RZ_NONNULL RzAnalysisJmpTableParams *params) |
Marks for analysis jump table cases with a space optimization for multiple cases corresponding to the same address. More... | |
RZ_API bool | rz_analysis_walkthrough_jmptbl (RZ_NONNULL RzAnalysis *analysis, RZ_NONNULL RzAnalysisFunction *fcn, RZ_NONNULL RzAnalysisBlock *block, RZ_NONNULL RzAnalysisJmpTableParams *params) |
Marks the jump table cases for analysis. More... | |
static bool | detect_casenum_shift (RzAnalysisOp *op, RzRegItem **cmp_reg, st64 *start_casenum_shift) |
RZ_API bool | rz_analysis_get_delta_jmptbl_info (RZ_NONNULL RzAnalysis *analysis, RZ_NONNULL RzAnalysisFunction *fcn, ut64 jmp_address, ut64 lea_address, RZ_NONNULL RzAnalysisJmpTableParams *params) |
Gets some necessary information about a jump table to perform analysis on. More... | |
RZ_API bool | rz_analysis_walkthrough_arm_jmptbl_style (RZ_NONNULL RzAnalysis *analysis, RZ_NONNULL RzAnalysisFunction *fcn, RZ_NONNULL RzAnalysisBlock *block, RZ_NONNULL RzAnalysisJmpTableParams *params) |
Marks for analysis ARM specific jump table cases. More... | |
RZ_API bool | rz_analysis_get_jmptbl_info (RZ_NONNULL RzAnalysis *analysis, RZ_NONNULL RzAnalysisFunction *fcn, RZ_NONNULL RzAnalysisBlock *block, ut64 jmp_address, RZ_NONNULL RzAnalysisJmpTableParams *params) |
Gets some necessary information about a jump table to perform analysis on. More... | |
#define aprintf | ( | format, | |
... | |||
) | RZ_LOG_DEBUG(format, __VA_ARGS__) |
|
static |
Definition at line 15 of file jmptbl.c.
References rz_flag_bind_t::f, rz_analysis_t::flb, PFMT64x, rz_analysis_block_add_switch_case(), rz_analysis_hint_set_immbase(), RZ_ANALYSIS_XREF_TYPE_CODE, rz_analysis_xrefs_set(), rz_meta_set_data_at(), rz_flag_bind_t::set, snprintf, and ut64().
Referenced by rz_analysis_walkthrough_arm_jmptbl_style(), rz_analysis_walkthrough_casetbl(), and rz_analysis_walkthrough_jmptbl().
|
static |
Definition at line 30 of file jmptbl.c.
References rz_flag_bind_t::f, rz_analysis_t::flb, PFMT64u, PFMT64x, RZ_ANALYSIS_XREF_TYPE_CODE, rz_analysis_xrefs_set(), rz_meta_set_string(), RZ_META_TYPE_COMMENT, rz_flag_bind_t::set, snprintf, autogen_x86imm::tmp, and UT64_MAX.
Referenced by rz_analysis_walkthrough_arm_jmptbl_style(), rz_analysis_walkthrough_casetbl(), and rz_analysis_walkthrough_jmptbl().
|
static |
Definition at line 255 of file jmptbl.c.
References RZ_ANALYSIS_OP_TYPE_ADD, RZ_ANALYSIS_OP_TYPE_LEA, RZ_ANALYSIS_OP_TYPE_MOV, RZ_ANALYSIS_OP_TYPE_SUB, st64, and UT64_MAX.
Referenced by rz_analysis_get_delta_jmptbl_info(), and rz_analysis_get_jmptbl_info().
|
inlinestatic |
Definition at line 60 of file jmptbl.c.
References ST32_MAX.
Referenced by rz_analysis_walkthrough_casetbl(), and rz_analysis_walkthrough_jmptbl().
RZ_API bool rz_analysis_get_delta_jmptbl_info | ( | RZ_NONNULL RzAnalysis * | analysis, |
RZ_NONNULL RzAnalysisFunction * | fcn, | ||
ut64 | jmp_address, | ||
ut64 | lea_address, | ||
RZ_NONNULL RzAnalysisJmpTableParams * | params | ||
) |
Gets some necessary information about a jump table to perform analysis on.
Gets amount of cases inside a jump table, the default case address and the case shift amount
analysis | Pointer to RzAnalysis instance |
fcn | Pointer to RzAnalysisFunction where jump table ocurred |
jmp_address | Address of jump intruction that uses the table |
lea_addr | Address of lea instruction that loads the address of the jump table base |
params | Pointer to RzAnalysisJmpTableParams where the results of the function are stored |
Definition at line 288 of file jmptbl.c.
References detect_casenum_shift(), rz_analysis_op_t::dst, rz_analysis_op_t::fail, free(), i, isValid(), rz_analysis_op_t::jump, len, malloc(), NULL, rz_analysis_op_t::refptr, rz_analysis_value_t::reg, rz_analysis_op_t::reg, rz_analysis_op(), rz_analysis_op_fini(), RZ_ANALYSIS_OP_MASK_BASIC, RZ_ANALYSIS_OP_MASK_VAL, RZ_ANALYSIS_OP_TYPE_CJMP, RZ_ANALYSIS_OP_TYPE_CMP, RZ_ANALYSIS_OP_TYPE_MASK, rz_reg_get(), RZ_REG_TYPE_ANY, rz_return_val_if_fail, rz_vector_fini(), rz_vector_foreach_prev, rz_vector_init(), rz_vector_push(), rz_analysis_op_t::src, type, rz_analysis_op_t::type, ut64(), UT64_MAX, v, and rz_analysis_op_t::val.
Referenced by run_basic_block_analysis().
RZ_API bool rz_analysis_get_jmptbl_info | ( | RZ_NONNULL RzAnalysis * | analysis, |
RZ_NONNULL RzAnalysisFunction * | fcn, | ||
RZ_NONNULL RzAnalysisBlock * | block, | ||
ut64 | jmp_address, | ||
RZ_NONNULL RzAnalysisJmpTableParams * | params | ||
) |
Gets some necessary information about a jump table to perform analysis on.
Gets amount of cases inside a jump table, the default case address and the case shift amount
analysis | Pointer to RzAnalysis instance |
fcn | Pointer to RzAnalysisFunction where jump table ocurred |
block | Pointer to RzAnalysisBlock where the jump instruction related to the jump table ocurred |
jmp_address | Address of jump intruction that uses the table |
params | Pointer to RzAnalysisJmpTableParams where the results of the function are stored |
Definition at line 443 of file jmptbl.c.
References rz_analysis_bb_t::addr, aprintf, buflen, calloc(), detect_casenum_shift(), rz_analysis_op_t::dst, rz_analysis_bb_t::fail, free(), i, isValid(), rz_analysis_bb_t::jump, len, rz_analysis_bb_t::ninstr, NULL, PFMT64x, rz_analysis_op_t::refptr, rz_analysis_value_t::reg, rz_analysis_op_t::reg, rz_analysis_block_get_op_addr(), rz_analysis_block_get_op_offset(), rz_analysis_hint_free(), rz_analysis_hint_get(), rz_analysis_op(), rz_analysis_op_fini(), RZ_ANALYSIS_OP_MASK_BASIC, RZ_ANALYSIS_OP_MASK_HINT, RZ_ANALYSIS_OP_MASK_VAL, RZ_ANALYSIS_OP_TYPE_CMP, RZ_ANALYSIS_OP_TYPE_MASK, rz_reg_get(), RZ_REG_TYPE_ANY, rz_return_val_if_fail, s, rz_analysis_bb_t::size, rz_analysis_op_t::src, type, rz_analysis_op_t::type, ut64(), UT64_MAX, val, rz_analysis_hint_t::val, and rz_analysis_op_t::val.
Referenced by run_basic_block_analysis().
RZ_API bool rz_analysis_jmptbl | ( | RzAnalysis * | analysis, |
RzAnalysisFunction * | fcn, | ||
RzAnalysisBlock * | block, | ||
ut64 | jmpaddr, | ||
ut64 | table, | ||
ut64 | tablesize, | ||
ut64 | default_addr | ||
) |
Definition at line 46 of file jmptbl.c.
References rz_analysis_walkthrough_jmptbl(), and UT64_MAX.
Referenced by rz_analysis_function_analyze_jmptable_handler().
RZ_API bool rz_analysis_walkthrough_arm_jmptbl_style | ( | RZ_NONNULL RzAnalysis * | analysis, |
RZ_NONNULL RzAnalysisFunction * | fcn, | ||
RZ_NONNULL RzAnalysisBlock * | block, | ||
RZ_NONNULL RzAnalysisJmpTableParams * | params | ||
) |
Marks for analysis ARM specific jump table cases.
This function works similarly to rz_analysis_walkthrough_jmptbl
, but is specific to ARM
analysis | Pointer to RzAnalysis instance |
fcn | Pointer to RzAnalysisFunction to add the new cases |
block | Pointer to RzAnalysisBlock that originates the switch table |
params | Pointer to RzAnalysisJmpTableParams necessary to analyze the jump table |
Definition at line 391 of file jmptbl.c.
References apply_case(), apply_switch(), NULL, rz_analysis_task_item_new(), rz_return_val_if_fail, UT32_MAX, ut64(), and UT64_MAX.
Referenced by run_basic_block_analysis().
RZ_API bool rz_analysis_walkthrough_casetbl | ( | RZ_NONNULL RzAnalysis * | analysis, |
RZ_NONNULL RzAnalysisFunction * | fcn, | ||
RZ_NONNULL RzAnalysisBlock * | block, | ||
RZ_NONNULL RzAnalysisJmpTableParams * | params | ||
) |
Marks for analysis jump table cases with a space optimization for multiple cases corresponding to the same address.
This function works similarly to rz_analysis_walkthrough_jmptbl
, with the difference that jump targets are hidden behind a indirection in the case table
analysis | Pointer to RzAnalysis instance |
fcn | Pointer to RzAnalysisFunction to add the new cases |
block | Pointer to RzAnalysisBlock that originates the switch table |
params | Pointer to RzAnalysisJmpTableParams necessary to analyze the jump table |
Definition at line 76 of file jmptbl.c.
References apply_case(), apply_switch(), aprintf, calloc(), free(), jmptable_size_is_invalid(), limit, NULL, PFMT64x, rz_analysis_hint_set_immbase(), rz_analysis_task_item_new(), rz_meta_set_data_at(), rz_read_le16(), rz_read_le32(), rz_read_le64(), rz_read_le8(), rz_return_val_if_fail, st32, UT32_MAX, ut64(), and UT64_MAX.
Referenced by run_basic_block_analysis().
RZ_API bool rz_analysis_walkthrough_jmptbl | ( | RZ_NONNULL RzAnalysis * | analysis, |
RZ_NONNULL RzAnalysisFunction * | fcn, | ||
RZ_NONNULL RzAnalysisBlock * | block, | ||
RZ_NONNULL RzAnalysisJmpTableParams * | params | ||
) |
Marks the jump table cases for analysis.
Goes through each case on the jump table, adds necessary flags/metadata and a new RzAnalysisTaskItem to params->tasks
to be analyzed later.
analysis | Pointer to RzAnalysis instance |
fcn | Pointer to RzAnalysisFunction to add the new cases |
block | Pointer to RzAnalysisBlock that originates the switch table |
params | Pointer to RzAnalysisJmpTableParams necessary to analyze the jump table |
Definition at line 176 of file jmptbl.c.
References apply_case(), apply_switch(), aprintf, calloc(), free(), is_arm(), jmptable_size_is_invalid(), limit, NULL, PFMT64x, rz_analysis_task_item_new(), rz_read_le16(), rz_read_le32(), rz_read_le64(), rz_read_le8(), rz_return_val_if_fail, st32, UT32_MAX, ut64(), and UT64_MAX.
Referenced by run_basic_block_analysis(), and rz_analysis_jmptbl().