(self)
return unassured_functions
Scan the entire program image for function prologues, and start code scanning at those positions

        :return: A list of possible function addresses
Scan the entire program image for function prologues, and start code scanning at those positions
Scan the entire program image for function prologues and start code scanning at those positions
def _func_addrs_from_prologues(self):
        """
        Scan the entire program image for function prologues, and start code scanning at those positions

        :return: A list of possible function addresses
        """

        # Pre-compile all regexes
        regexes = list()
        for ins_regex in self.project.arch.function_prologs:
            r = re.compile(ins_regex)
            regexes.append(r)
        # EDG says: I challenge anyone bothering to read this to come up with a better
        # way to handle CPU modes that affect instruction decoding.
        # Since the only one we care about is ARM/Thumb right now
        # we have this gross hack. Sorry about that.
        thumb_regexes = list()
        if hasattr(self.project.arch, 'thumb_prologs'):
            for ins_regex in self.project.arch.thumb_prologs:
                # Thumb prologues are found at even addrs, but their actual addr is odd!
                # Isn't that great?
                r = re.compile(ins_regex)
                thumb_regexes.append(r)

        # Construct the binary blob first
        unassured_functions = [ ]

        is_arm = is_arm_arch(self.project.arch)

        for start_, bytes_ in self._binary.memory.backers():
            for regex in regexes:
                # Match them!
                for mo in regex.finditer(bytes_):
                    position = mo.start() + start_
                    if (not is_arm and position % self.project.arch.instruction_alignment == 0) or \
                            (is_arm and position % 4 == 0):
                        mapped_position = AT.from_rva(position, self._binary).to_mva()
                        if self._addr_in_exec_memory_regions(mapped_position):
                            unassured_functions.append(mapped_position)
            # HACK part 2: Yes, i really have to do this
            for regex in thumb_regexes:
                # Match them!
                for mo in regex.finditer(bytes_):
                    position = mo.start() + start_
                    if position % self.project.arch.instruction_alignment == 0:
                        mapped_position = AT.from_rva(position, self._binary).to_mva()
                        if self._addr_in_exec_memory_regions(mapped_position):
                            unassured_functions.append(mapped_position+1)

        l.info("Found %d functions with prologue scanning.", len(unassured_functions))
        return unassured_functions
def _func_addrs_from_prologues ( self ) : # Pre-compile all regexes regexes = list ( ) for ins_regex in self . project . arch . function_prologs : r = re . compile ( ins_regex ) regexes . append ( r ) # EDG says: I challenge anyone bothering to read this to come up with a better # way to handle CPU modes that affect instruction decoding. # Since the only one we care about is ARM/Thumb right now # we have this gross hack. Sorry about that. thumb_regexes = list ( ) if hasattr ( self . project . arch , 'thumb_prologs' ) : for ins_regex in self . project . arch . thumb_prologs : # Thumb prologues are found at even addrs, but their actual addr is odd! # Isn't that great? r = re . compile ( ins_regex ) thumb_regexes . append ( r ) # Construct the binary blob first unassured_functions = [ ] is_arm = is_arm_arch ( self . project . arch ) for start_ , bytes_ in self . _binary . memory . backers ( ) : for regex in regexes : # Match them! for mo in regex . finditer ( bytes_ ) : position = mo . start ( ) + start_ if ( not is_arm and position % self . project . arch . instruction_alignment == 0 ) or ( is_arm and position % 4 == 0 ) : mapped_position = AT . from_rva ( position , self . _binary ) . to_mva ( ) if self . _addr_in_exec_memory_regions ( mapped_position ) : unassured_functions . append ( mapped_position ) # HACK part 2: Yes, i really have to do this for regex in thumb_regexes : # Match them! for mo in regex . finditer ( bytes_ ) : position = mo . start ( ) + start_ if position % self . project . arch . instruction_alignment == 0 : mapped_position = AT . from_rva ( position , self . _binary ) . to_mva ( ) if self . _addr_in_exec_memory_regions ( mapped_position ) : unassured_functions . append ( mapped_position + 1 ) l . info ( "Found %d functions with prologue scanning." , len ( unassured_functions ) ) return unassured_functions