コード例 #1
0
ファイル: ghida.py プロジェクト: secretnonempty/GhIDA
 def OnClick(self, shift):
     """
     User clicked in the view
     @param shift: Shift flag
     @return: Boolean. True if you handled the event
     """
     return gl.highlight_symbol_in_DISASM()
コード例 #2
0
ファイル: ghida.py プロジェクト: secretnonempty/GhIDA
    def rename_symbol(self):
        """
        Rename the symbol "symbol" with the new name
        provided by the user in the Pop-Up
        """
        # Get the symbol
        symbol = get_highlighted_identifier()
        if not symbol:
            idaapi.warning("Select a symbol")
            return False

        # Get the address
        address = gl.get_address_for_symbol(symbol)
        if not address:
            print("GhIDA:: [!] Symbol %s not found" % symbol)
            return False

        # Display a Pop-up to get the new name
        new_name = gl.display_rename_form(address, symbol)
        if not new_name or len(new_name) == 0:
            return

        # Check for white_spaces in the new symbol name
        for letter in new_name:
            if not (letter.isdigit() or letter.isalpha() or letter == '_'):
                print("GhIDA:: [!] symbol name contains invalid char")
                return

        # Check if new_name is already used
        if gl.check_if_symbol_is_used(new_name):
            print("GhIDA:: [!] symble name already used")
            return

        # Update symbol name in SYMBLE DICT:
        gl.updated_symbol_name_for_address(symbol, address, new_name)

        # Update symbol name in IDA DISASM view.
        print("GhIDA:: [DEBUG] New symbol name: %s" % new_name)

        # Update symbol name in the decompiled view
        new_code = gl.rename_variable_in_text(self.__decompiled, symbol,
                                              new_name)
        self.update(self.__ea, new_code)

        # Add comments
        comment_list = COMMENTS_CACHE.get_comments_cache(self.__ea)
        if comment_list:
            self.add_comments(comment_list)

        print("GhIDA:: [INFO] Symbol name updated in IDA DECOMP view.")

        if idc.set_name(address, new_name):
            # Refresh the view
            idaapi.request_refresh(idaapi.IWID_DISASMS)
            # Highlight the new identifier
            gl.highlight_symbol_in_DISASM()
            print("GhIDA:: [INFO] Symbol name updated in IDA DISASM view.")
            return

        print("GhIDA:: [!] IDA DISASM rename error")
        return