Example #1
0
def make_var_expr(number, type, m, arg=False):
    if arg is False:
        expr = ida_hexrays.cexpr_t()
    else:
        expr = ida_hexrays.carg_t()
    expr.op = ida_hexrays.cot_var
    expr.v = ida_hexrays.var_ref_t()
    expr.v.idx = number
    expr.type = type
    expr.v.mba = m
    return expr
Example #2
0
def make_obj_expr(ea, type=None, arg=False):
    if arg is False:
        expr = ida_hexrays.cexpr_t()
    else:
        expr = ida_hexrays.carg_t()
    expr.op = ida_hexrays.cot_obj
    expr.obj_ea = ea
    if type is None:
        expr.type = ida_hexrays.dummy_ptrtype(4, False)
    else:
        expr.type = type
    return expr
Example #3
0
                def visit_expr(self, e):
                    if not e.x or e.x.op != ida_hexrays.cot_helper:
                        return 0

                    insn = ida_ua.insn_t()
                    ida_ua.decode_insn(insn, e.ea)

                    def make_reg(cp_reg):
                        reg = ida_hexrays.carg_t()
                        reg.op = ida_hexrays.cot_helper
                        reg.helper = cp_reg
                        reg.exflags = ida_hexrays.EXFL_ALONE
                        return reg

                    if e.x.helper in ["__mcr", "__mrc"]:
                        cp_reg = plugin.arch.decode_mcr_mrc(insn)[0]
                        if cp_reg:
                            if e.x.helper == "__mcr":
                                e.x.helper = "_WriteStatusReg"
                                val = ida_hexrays.carg_t()
                                e.a[2].swap(val)
                                e.a.clear()
                                e.a.push_back(make_reg(cp_reg))
                                e.a.push_back(val)

                            else:
                                e.x.helper = "_ReadStatusReg"
                                e.a.clear()
                                e.a.push_back(make_reg(cp_reg))

                    elif e.x.helper == "ARM64_SYSREG":
                        cp_reg = plugin.arch.decode_msr_mrs(insn)[0]
                        if cp_reg:
                            e.replace_by(make_reg(cp_reg))

                    return 0
Example #4
0
 def make_reg(cp_reg):
     reg = ida_hexrays.carg_t()
     reg.op = ida_hexrays.cot_helper
     reg.helper = cp_reg
     reg.exflags = ida_hexrays.EXFL_ALONE
     return reg
Example #5
0
def make_carg_t(cexpr): # type: (hr.cexpr_t) -> hr.carg_t
    arg = hr.carg_t()
    arg.assign(cexpr)
    return arg