def Entries(): """ Returns a list of entry points @return: List of tuples (index, ordinal, ea, name) """ n = idaapi.get_entry_qty() for i in xrange(0, n): ordinal = idaapi.get_entry_ordinal(i) ea = idaapi.get_entry(ordinal) name = idaapi.get_entry_name(ordinal) yield (i, ordinal, ea, name)
def find_entrypoint(self): ordinal = 0 number_entry = idaapi.get_entry_qty() print("Number of Entry point: " + str(number_entry)) ordinal = idaapi.get_entry_ordinal(number_entry - 1) print("Entry ordinals: " + str(ordinal)) self.entryaddress = idaapi.get_entry(ordinal) self.entryname = idaapi.get_entry_name(ordinal) print("Entry : " + self.entryname + " " + str(self.entryaddress))
def Entries(): """ Returns a list of entry points @return: List of tuples (index, ordinal, ea, name) """ n = idaapi.get_entry_qty() for i in xrange(0, n): ordinal = idaapi.get_entry_ordinal(i) ea = idaapi.get_entry(ordinal) name = idaapi.get_entry_name(ordinal) yield (i, ordinal, ea, name)
def make_func_sigs(config): logger = logging.getLogger("idb2pat:make_func_sigs") sigs = [] if config.mode == USER_SELECT_FUNCTION: f = idaapi.choose_func("Choose Function:", idc.BADADDR) if f is None: logger.error("No function selected") return [] idc.jumpto(f.start_ea) if not idaapi.has_any_name(idc.get_full_flags(f.start_ea)): logger.error("Function doesn't have a name") return [] try: sigs.append(make_func_sig(config, f)) except Exception as e: logger.exception(e) logger.error("Failed to create signature for function at %s (%s)", hex(f.start_ea), idc.get_func_name(f.start_ea) or "") elif config.mode == NON_AUTO_FUNCTIONS: for f in get_functions(): # HTC - remove check FUNC_LIB flag to include library functions if idaapi.has_name(idc.get_full_flags(f.start_ea)): # and f.flags & idc.FUNC_LIB == 0: try: sigs.append(make_func_sig(config, f)) except FuncTooShortException: pass except Exception as e: logger.exception(e) logger.error( "Failed to create signature for function at %s (%s)", hex(f.start_ea), idc.get_name(f.start_ea) or "") elif config.mode == LIBRARY_FUNCTIONS: for f in get_functions(): if idaapi.has_name(idc.get_full_flags( f.start_ea)) and f.flags & idc.FUNC_LIB != 0: try: sigs.append(make_func_sig(config, f)) except FuncTooShortException: pass except Exception as e: logger.exception(e) logger.error( "Failed to create signature for function at %s (%s)", hex(f.start_ea), idc.get_name(f.start_ea) or "") elif config.mode == PUBLIC_FUNCTIONS: for f in get_functions(): if idaapi.is_public_name(f.start_ea): try: sigs.append(make_func_sig(config, f)) except FuncTooShortException: pass except Exception as e: logger.exception(e) logger.error( "Failed to create signature for function at %s (%s)", hex(f.start_ea), idc.get_name(f.start_ea) or "") elif config.mode == ENTRY_POINT_FUNCTIONS: for i in zrange(idaapi.get_func_qty()): f = idaapi.get_func(idaapi.get_entry(idaapi.get_entry_ordinal(i))) if f is not None: try: sigs.append(make_func_sig(config, f)) except FuncTooShortException: pass except Exception as e: logger.exception(e) logger.error( "Failed to create signature for function at %s (%s)", hex(f.start_ea), idc.get_name(f.start_ea) or "") elif config.mode == ALL_FUNCTIONS: n = idaapi.get_func_qty() for i, f in enumerate(get_functions()): try: logger.info("[ %d / %d ] %s %s", i + 1, n, idc.get_name(f.start_ea), hex(f.start_ea)) sigs.append(make_func_sig(config, f)) except FuncTooShortException: pass except Exception as e: logger.exception(e) logger.error( "Failed to create signature for function at %s (%s)", hex(f.start_ea), idc.get_name(f.start_ea) or "") return sigs