mirror of
https://github.com/radareorg/radare2.git
synced 2024-11-23 21:29:49 +00:00
fixed up usage of new for switch
This commit is contained in:
parent
989bc540cf
commit
34e24736e5
@ -105,7 +105,8 @@ R_API void r_anal_ex_clone_op_switch_to_bb (RAnalBlock *bb, RAnalOp *op) {
|
||||
RAnalCaseOp *caseop = NULL;
|
||||
|
||||
if ( op->switch_op ) {
|
||||
bb->switch_op = r_anal_switch_op_init (op->switch_op->addr,
|
||||
|
||||
bb->switch_op = r_anal_switch_op_new (op->switch_op->addr,
|
||||
op->switch_op->min_val,
|
||||
op->switch_op->max_val);
|
||||
|
||||
|
@ -464,7 +464,7 @@ static int analyze_method(RAnal *anal, RAnalFunction *fcn, RAnalState *state) {
|
||||
state->current_fcn = fcn;
|
||||
r_anal_ex_perform_analysis (anal, state, fcn->addr);
|
||||
bytes_consumed = state->bytes_consumed;
|
||||
IFDBG eprintf("analyze_method: Completed Parsing fcn %s @ 0x%08"PFMT64x", consumed %d bytes\n", fcn->name, fcn->addr, bytes_consumed);
|
||||
IFDBG eprintf("analyze_method: Completed Parsing fcn %s @ 0x%08"PFMT64x", consumed %d"PFMT64d" bytes\n", fcn->name, fcn->addr, bytes_consumed);
|
||||
|
||||
return state->anal_ret_val;
|
||||
}
|
||||
@ -565,7 +565,7 @@ static int java_switch_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *data,
|
||||
ut32 default_loc = (ut32)(UINT (data, pos)),
|
||||
cur_case = 0;
|
||||
|
||||
op->switch_op = r_anal_switch_op_init (addr, min_val, default_loc);
|
||||
op->switch_op = r_anal_switch_op_new (addr, min_val, default_loc);
|
||||
|
||||
RAnalCaseOp *caseop = NULL;
|
||||
IFDBG {
|
||||
@ -586,6 +586,7 @@ static int java_switch_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *data,
|
||||
}
|
||||
}
|
||||
op->size = pos;
|
||||
return op->size;
|
||||
}
|
||||
static int java_op(RAnal *anal, RAnalOp *op, ut64 addr, const ut8 *data, int len) {
|
||||
unsigned int i;
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include <r_anal.h>
|
||||
|
||||
|
||||
R_API RAnalSwitchOp *r_anal_switch_op_new() {
|
||||
RAnalSwitchOp *switch_op_new() {
|
||||
RAnalSwitchOp * swop = R_NEW0 (RAnalSwitchOp);
|
||||
swop->cases = r_list_new ();
|
||||
swop->cases->free = (void *)free;
|
||||
@ -9,12 +9,14 @@ R_API RAnalSwitchOp *r_anal_switch_op_new() {
|
||||
return swop;
|
||||
}
|
||||
|
||||
R_API RAnalSwitchOp *r_anal_switch_op_init(ut64 addr, ut64 min_val, ut64 def_val) {
|
||||
RAnalSwitchOp * swop = r_anal_switch_op_new();
|
||||
swop->addr = addr;
|
||||
swop->min_val = min_val;
|
||||
swop->def_val = min_val;
|
||||
swop->max_val = min_val;
|
||||
R_API RAnalSwitchOp * r_anal_switch_op_new(ut64 addr, ut64 min_val, ut64 def_val) {
|
||||
RAnalSwitchOp *swop = switch_op_new();
|
||||
if (swop) {
|
||||
swop->addr = addr;
|
||||
swop->min_val = min_val;
|
||||
swop->def_val = min_val;
|
||||
swop->max_val = min_val;
|
||||
}
|
||||
return swop;
|
||||
}
|
||||
|
||||
|
@ -723,7 +723,7 @@ typedef struct r_anal_state_type_t {
|
||||
ut32 max_depth;
|
||||
|
||||
void *user_state;
|
||||
} RAnalInfos;
|
||||
} RAnalState;
|
||||
|
||||
typedef int (*RAnalCmdExt)(/* Rcore */void *core, RAnal *anal, const char* input);
|
||||
typedef int (*RAnalAnalyzeFunctions)(RAnal *a, ut64 at, ut64 from, int reftype, int depth);
|
||||
@ -1068,27 +1068,26 @@ R_API int r_anal_esil_eval(RAnal *anal, const char *str);
|
||||
|
||||
|
||||
/* switch.c APIs */
|
||||
R_API RAnalSwitchOp *r_anal_switch_op_new();
|
||||
R_API RAnalSwitchOp *r_anal_switch_op_init(ut64 addr, ut64 min_val, ut64 max_val);
|
||||
R_API RAnalSwitchOp * r_anal_switch_op_new(ut64 addr, ut64 min_val, ut64 max_val);
|
||||
R_API void r_anal_switch_op_free(RAnalSwitchOp * swop);
|
||||
R_API RAnalCaseOp* r_anal_switch_op_add_case(RAnalSwitchOp * swop, ut64 addr, ut64 jump, ut64 value);
|
||||
|
||||
/*
|
||||
* RAnalInfos maintains state during analysis.
|
||||
* RAnalState maintains state during analysis.
|
||||
* there are standard values current_fcn, current_op, current_bb, addr,
|
||||
* data buffer, etc. but there is also a void * for user defined structures
|
||||
* that can be updated during the callbacks.
|
||||
*/
|
||||
R_API RAnalInfos * r_anal_state_new (ut64 start, ut8* buffer, ut64 len);
|
||||
R_API void r_anal_state_insert_bb (RAnalInfos* state, RAnalBlock *bb);
|
||||
R_API int r_anal_state_need_rehash (RAnalInfos* state, RAnalBlock *bb);
|
||||
R_API RAnalBlock * r_anal_state_search_bb (RAnalInfos* state, ut64 addr);
|
||||
R_API void r_anal_state_free (RAnalInfos * state);
|
||||
R_API ut64 r_anal_state_get_len (RAnalInfos *state, ut64 addr);
|
||||
R_API const ut8 * r_anal_state_get_buf_by_addr (RAnalInfos *state, ut64 addr);
|
||||
R_API int r_anal_state_addr_is_valid (RAnalInfos *state, ut64 addr);
|
||||
R_API void r_anal_state_merge_bb_list (RAnalInfos *state, RList* bbs);
|
||||
R_API void r_anal_state_set_depth(RAnalInfos *state, ut32 depth);
|
||||
R_API RAnalState * r_anal_state_new (ut64 start, ut8* buffer, ut64 len);
|
||||
R_API void r_anal_state_insert_bb (RAnalState* state, RAnalBlock *bb);
|
||||
R_API int r_anal_state_need_rehash (RAnalState* state, RAnalBlock *bb);
|
||||
R_API RAnalBlock * r_anal_state_search_bb (RAnalState* state, ut64 addr);
|
||||
R_API void r_anal_state_free (RAnalState * state);
|
||||
R_API ut64 r_anal_state_get_len (RAnalState *state, ut64 addr);
|
||||
R_API const ut8 * r_anal_state_get_buf_by_addr (RAnalState *state, ut64 addr);
|
||||
R_API int r_anal_state_addr_is_valid (RAnalState *state, ut64 addr);
|
||||
R_API void r_anal_state_merge_bb_list (RAnalState *state, RList* bbs);
|
||||
R_API void r_anal_state_set_depth(RAnalState *state, ut32 depth);
|
||||
|
||||
|
||||
/* plugin pointers */
|
||||
|
@ -291,7 +291,7 @@ enum {
|
||||
|
||||
// BB and OP
|
||||
R_API ut64 r_anal_ex_map_anal_ex_to_anal_op_type(ut64 ranal2_op_type);
|
||||
R_API void r_anal_ex_op_to_bb(RAnal *anal, RAnalInfos *state, RAnalBlock *bb, RAnalOp *op);
|
||||
R_API void r_anal_ex_op_to_bb(RAnal *anal, RAnalState *state, RAnalBlock *bb, RAnalOp *op);
|
||||
R_API int r_anal_ex_is_op_type_eop(ut64 x);
|
||||
|
||||
R_API ut32 r_anal_ex_map_anal_ex_to_anal_bb_type (ut64 ranal2_op_type);
|
||||
@ -300,13 +300,13 @@ R_API ut32 r_anal_ex_map_anal_ex_to_anal_bb_type (ut64 ranal2_op_type);
|
||||
* is present, then that will be the algorithm used for analyzing the code
|
||||
* or data
|
||||
*/
|
||||
R_API RList * r_anal_ex_analyze( RAnal *anal, RAnalInfos *state, ut64 addr);
|
||||
R_API RList * r_anal_ex_analysis_driver( RAnal *anal, RAnalInfos *state, ut64 addr);
|
||||
R_API RList * r_anal_ex_analyze( RAnal *anal, RAnalState *state, ut64 addr);
|
||||
R_API RList * r_anal_ex_analysis_driver( RAnal *anal, RAnalState *state, ut64 addr);
|
||||
|
||||
// BB and OP handling
|
||||
R_API void r_anal_ex_update_bb_cfg_head_tail( RAnalBlock *start, RAnalBlock * head, RAnalBlock * tail );
|
||||
R_API RAnalOp * r_anal_ex_get_op(RAnal *anal, RAnalInfos *state, ut64 addr);
|
||||
R_API RAnalBlock * r_anal_ex_get_bb(RAnal *anal, RAnalInfos *state, ut64 addr);
|
||||
R_API RAnalOp * r_anal_ex_get_op(RAnal *anal, RAnalState *state, ut64 addr);
|
||||
R_API RAnalBlock * r_anal_ex_get_bb(RAnal *anal, RAnalState *state, ut64 addr);
|
||||
R_API void r_anal_ex_clone_op_switch_to_bb (RAnalBlock *bb, RAnalOp *op);
|
||||
|
||||
// used to perform comparisons on BB to determine if BB are in same body
|
||||
|
Loading…
Reference in New Issue
Block a user