forked from nihilus/hexrays_tools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsnippet.cpp
More file actions
executable file
·67 lines (56 loc) · 1.27 KB
/
Copy pathsnippet.cpp
File metadata and controls
executable file
·67 lines (56 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
void convert_test(cexpr_t *e)
{
// sub -> num , var => helper object
if (e->op == cot_sub)
{
cexpr_t *var = e->x;
if (var->op == cot_cast)
var = var->x;
cexpr_t * num = e->y;
if(var->op == cot_var && num->op == cot_num)
{
typestring t = make_pointer( create_typedef("_DWORD"));
cexpr_t * ce = create_helper(t, "test");//make_num(10);
e->cleanup();//delete
e->replace_by(ce);
}
}
}
static void convert_zeroes(cfunc_t *cfunc)
{
struct zero_converter_t : public ctree_visitor_t
{
zero_converter_t(void) : ctree_visitor_t(CV_FAST) {}
int idaapi visit_expr(cexpr_t *e)
{
switch ( e->op )
{
case cot_sub: // B
{
convert_test(e);
}
break;
}
return 0; // continue walking the tree
}
};
zero_converter_t zc;
zc.apply_to(&cfunc->body, NULL);
}
static int idaapi callback(void *, hexrays_event_t event, va_list va)
{
switch ( event )
{
case hxe_maturity:
{
cfunc_t *cfunc = va_arg(va, cfunc_t *);
ctree_maturity_t new_maturity = va_argi(va, ctree_maturity_t);
if ( new_maturity == CMAT_FINAL ) // ctree is ready
{
convert_zeroes(cfunc);
}
}
break;
}
return 0;
}