def make_helper_call(ret_type, name, arg_types): # type: (str, str, typing.List[str]) -> hr.cexpr_t """Make a call expression to a helper function (non-existing function with arbitrary name).""" helper_expr = hr.cexpr_t() helper_expr.ea = idaapi.BADADDR helper_expr.op = hr.cot_helper helper_expr.helper = name call_expr = hr.cexpr_t() call_expr.op = hr.cot_call call_expr.x = helper_expr call_expr.a = hr.carglist_t() # EXTREMELY IMPORTANT: set the expression types. Without this, Hex-Rays will crash # in mysterious ways. t = idaapi.tinfo_t() idaapi.parse_decl2(idaapi.cvar.idati, "%s (__cdecl *)(%s);" % (ret_type, ','.join(arg_types)), t, idaapi.PT_TYP) helper_expr.type = t call_expr.a.functype = t call_expr.type = t.get_rettype() return call_expr
def make_call_expr(fcnexpr, args): expr = ida_hexrays.cexpr_t() expr.op = ida_hexrays.cot_call expr.x = fcnexpr expr.a = ida_hexrays.carglist_t() return expr