Skip to main content
Glama

ida_rename_function

Renames a function in an IDA database by specifying the old and new function names. Facilitates easy updates and organization within reverse engineering workflows.

Instructions

Rename a function in the IDA database

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
new_nameYes
old_nameYes

Implementation Reference

  • Pydantic input schema model for the 'ida_rename_function' tool, defining old_name and new_name parameters.
    class RenameFunction(BaseModel): old_name: str new_name: str
  • Registration of the 'ida_rename_function' tool in the MCP server's list_tools() function.
    Tool( name=IDATools.RENAME_FUNCTION, description="Rename a function in the IDA database", inputSchema=RenameFunction.schema(), ),
  • MCP server tool call handler for 'ida_rename_function' that calls IDAProFunctions.rename_function() and returns the result as text content.
    case IDATools.RENAME_FUNCTION: result: str = ida_functions.rename_function( arguments["old_name"], arguments["new_name"] ) return [TextContent( type="text", text=result )]
  • Proxy handler in IDAProFunctions class that sends 'rename_function' request to IDA Pro plugin via communicator and formats the response.
    def rename_function(self, old_name: str, new_name: str) -> str: """Rename a function""" try: response: Dict[str, Any] = self.communicator.send_request( "rename_function", {"old_name": old_name, "new_name": new_name} ) if "error" in response: return f"Error renaming function from '{old_name}' to '{new_name}': {response['error']}" success: bool = response.get("success", False) message: str = response.get("message", "") if success: return f"Successfully renamed function from '{old_name}' to '{new_name}': {message}" else: return f"Failed to rename function from '{old_name}' to '{new_name}': {message}" except Exception as e: self.logger.error(f"Error renaming function: {str(e)}", exc_info=True) return f"Error renaming function from '{old_name}' to '{new_name}': {str(e)}"
  • Core implementation of function renaming in IDA Pro plugin: resolves function by name, renames using ida_name.set_name(), refreshes views. This is the exact logic that performs the rename.
    def rename_function(self, old_name: str, new_name: str) -> Dict[str, Any]: """Rename a function""" return self._rename_function_internal(old_name, new_name) def _rename_function_internal(self, old_name: str, new_name: str) -> Dict[str, Any]: """Internal implementation for rename_function without sync wrapper""" try: # Get function address func_addr: int = ida_name.get_name_ea(0, old_name) if func_addr == idaapi.BADADDR: return {"success": False, "message": f"Function '{old_name}' not found"} # Check if it's a function func: Optional[ida_funcs.func_t] = ida_funcs.get_func(func_addr) if not func: return {"success": False, "message": f"'{old_name}' is not a function"} # Check if new name is already in use if ida_name.get_name_ea(0, new_name) != idaapi.BADADDR: return {"success": False, "message": f"Name '{new_name}' is already in use"} # Try to rename if not ida_name.set_name(func_addr, new_name): return {"success": False, "message": f"Failed to rename function, possibly due to invalid name format or other IDA restrictions"} # Refresh view self._refresh_view_internal() return {"success": True, "message": f"Function renamed from '{old_name}' to '{new_name}' at address {hex(func_addr)}"} except Exception as e: print(f"Error renaming function: {str(e)}") traceback.print_exc() return {"success": False, "message": str(e)}

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/MxIris-Reverse-Engineering/ida-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server