def declaration(string): if idaapi.__version__ < 7.0: res = idaapi.demangle_name(internal.utils.string.to(string), idaapi.cvar.inf.long_demnames) else: res = idaapi.demangle_name(internal.utils.string.to(string), idaapi.cvar.inf.long_demnames, idaapi.DQT_FULL) return string if res is None else internal.utils.string.of(res)
def demangle(string): '''Given a mangled C++ `string`, demangle it back into a human-readable symbol.''' if idaapi.__version__ < 7.0: res = idaapi.demangle_name(internal.utils.string.to(string), idaapi.cvar.inf.long_demnames) else: res = idaapi.demangle_name(internal.utils.string.to(string), idaapi.cvar.inf.long_demnames, idaapi.DQT_FULL) return string if res is None else internal.utils.string.of(res)
def _replace_with_check_helper(self, ctx, l): # type: (...) -> None type_name_ea = ctx.type_info_obj.obj_ea name = idaapi.demangle_name(idaapi.get_name(type_name_ea), 0) if not name: name = idaapi.get_name(type_name_ea) type_name = name var_type = None if "::getRuntimeTypeInfoStatic(void)::typeInfo" in name: type_name = name.split("::getRuntimeTypeInfoStatic(void)::typeInfo")[0] var_type = idaapi.tinfo_t() idaapi.parse_decl2(idaapi.cvar.idati, type_name + "*;", var_type, idaapi.PT_TYP) if not str(var_type): var_type = None call_expr = make_helper_call("void*", "dynamic_cast<" + type_name + ">", ["void*"]) call_expr.a.push_back(make_carg_t(ctx.original_var)) asg_expr = hr.cexpr_t() asg_expr.op = hr.cot_asg asg_expr.x = hr.cexpr_t() asg_expr.x.assign(ctx.dynamic_cast_var) asg_expr.y = call_expr asg_expr.type = var_type if var_type else idaapi.tinfo_t(idaapi.BT_VOID) if var_type: self._types_to_set.append((ctx.dynamic_cast_var.v.idx, var_type)) replace_expr_with(l[0].cexpr, asg_expr) for item in l[1:]: item.cleanup()
def makeName(ea): locName = '??_R0' + getAsciiz(ea + 9) + '@8' if idaapi.demangle_name(locName, 0) == '': raise RttiError( "%08X: Location name failed to properly demangle: `%s'" % (ea, locName)) return locName
def demangle(name, disable_mask=0): try: demangled_name = idaapi.demangle_name2(name, disable_mask) except AttributeError: # Backwards compatibility with IDA 6.6 demangled_name = idaapi.demangle_name(name, disable_mask) if demangled_name: return demangled_name return name
def demangled(self): """Return the demangled name of the function. If none exists, return `.name`""" try: name = idaapi.demangle_name2(self.name, 0) except AttributeError: # Backwards compatibility with IDA 6.6 name = idaapi.demangle_name(self.name, 0) if name: return name return self.name
def maybe_get_name(ea): name = hex(ea) funcname = idaapi.get_func_name(ea) if not funcname: return name demangled_name = idaapi.demangle_name(funcname, idaapi.cvar.inf.short_demnames) if not demangled_name: return funcname return demangled_name
def check(self, expression, ctx) -> bool: if self.ea is None: return True if self.ea == expression.obj_ea: return True ea_name = idaapi.get_name(expression.obj_ea) if self.name == ea_name: return True demangled_ea_name = idaapi.demangle_name(ea_name, idaapi.MNG_NODEFINIT | idaapi.MNG_NORETTYPE) return demangled_ea_name == self.name
def __init__(self, ea): name = ea + get_member_by_name(self.struc, "name").soff strlen = u.get_strlen(name) if strlen is None: # not a real vtable return self.size = self.size + strlen mangled = get_ascii_contents(name, strlen, 0) if mangled is None: # not a real function name return print "Mangled: " + mangled demangled = demangle_name('??_R0' + mangled[1:], 0) if demangled: do_unknown_range(ea, self.size, DOUNK_DELNAMES) if doStruct(ea, self.size, self.tid): print " Made td at 0x%x: %s" % (ea, demangled) self.class_name = demangled return print " FAIL :(" return
def __init__(self, ea): name = ea + get_member_by_name(get_struc(self.tid), "name").soff strlen = u.get_strlen(name) if strlen is None: # not a real vtable return self.size = self.size + strlen mangled = get_strlit_contents(name, strlen, 0) if mangled is None: # not a real function name return print("Mangled: " + mangled) demangled = demangle_name('??_R0' + mangled[1:], 0) if demangled: del_items(ea, self.size, DELIT_DELNAMES) if create_struct(ea, self.size, self.tid): print(" Made td at 0x%x: %s" % (ea, demangled)) self.class_name = demangled return print(" FAIL :(") return
def define_vtables(): segments = util.enum_all_segments() vtables_total = 0 for segm in segments: addr = segm.start_ea while addr < segm.end_ea: funcs_counted = VirtualTable.check(addr) if funcs_counted: print 'Found possible vtable: %#x (%s) with %d functions' % ( addr, repr( idaapi.demangle_name( idaapi.get_ea_name(addr), idc.get_inf_attr( idc.INF_SHORT_DN))), funcs_counted) v = VirtualTable(addr) v.finalize() addr += funcs_counted * const.PTR_SIZE vtables_total += 1 addr += const.PTR_SIZE print '[!] Imported %d virtual tables in total!' % vtables_total
def declaration(string): res = idaapi.demangle_name(internal.utils.string.to(string), idaapi.cvar.inf.long_demnames) return string if res is None else internal.utils.string.of(res)
def demangle(name, disable_mask=0): demangled_name = idaapi.demangle_name(name, disable_mask, idaapi.DQT_FULL) if demangled_name: return demangled_name return name
def makeName(ea): locName = "??_R0" + getAsciiz(ea + 9) + "@8" if idaapi.demangle_name(locName, 0) == "": raise RttiError("%08X: Location name failed to properly demangle: `%s'" % (ea, locName)) return locName
def typeName(self): return idaapi.demangle_name("?x@@3" + self.mangledName + "A", 0)[:-2]
def typeName(self): return idaapi.demangle_name('?x@@3' + self.mangledName + 'A', 0)[:-2]
def declaration(string): result = idaapi.demangle_name(string, idaapi.cvar.inf.long_demnames) return string if result is None else result