Skip to main content
Glama
0xhackerfren

Frida Game Hacking MCP

by 0xhackerfren

write_memory

Modify game memory values by writing data to specific addresses for debugging, cheating, or reverse engineering purposes.

Instructions

Write data to memory address.

Args:
    address: Memory address (hex string like "0x401234")
    data: Data to write (hex string, or value if value_type specified)
    value_type: Type of data ("bytes", "int32", "float", "string", etc.)

Returns:
    Write status.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
addressYes
dataYes
value_typeNobytes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function decorated with @mcp.tool() that executes the write_memory tool. It validates attachment, parses and packs the data into bytes, injects a Frida JavaScript script to perform the memory write using Memory.writeByteArray, and returns success status with details.
    @mcp.tool()
    def write_memory(address: str, data: str, value_type: str = "bytes") -> Dict[str, Any]:
        """
        Write data to memory address.
        
        Args:
            address: Memory address (hex string like "0x401234")
            data: Data to write (hex string, or value if value_type specified)
            value_type: Type of data ("bytes", "int32", "float", "string", etc.)
        
        Returns:
            Write status.
        """
        global _session
        
        if not _session.is_attached():
            return {"error": "Not attached. Use attach() first."}
        
        try:
            addr = int(address, 16) if address.startswith("0x") else int(address)
            
            if value_type == "bytes":
                write_bytes = bytes.fromhex(data.replace(" ", ""))
            elif value_type in ("int8", "uint8", "int16", "uint16", "int32", "uint32",
                               "int64", "uint64", "float", "double"):
                value = float(data) if value_type in ("float", "double") else int(data)
                write_bytes = _pack_value(value, value_type)
            elif value_type == "string":
                write_bytes = data.encode('utf-8') + b'\x00'
            else:
                write_bytes = bytes.fromhex(data.replace(" ", ""))
            
            byte_array = ", ".join(f"0x{b:02x}" for b in write_bytes)
            script_code = f"""
            var addr = ptr("{hex(addr)}");
            Memory.writeByteArray(addr, [{byte_array}]);
            send("done");
            """
            
            script = _session.session.create_script(script_code)
            script.on('message', lambda m, d: None)
            script.load()
            script.unload()
            
            return {
                "success": True,
                "address": hex(addr),
                "bytes_written": len(write_bytes),
                "data_hex": write_bytes.hex()
            }
        
        except Exception as e:
            return {"error": f"Failed to write memory: {str(e)}"}
  • Supporting utility function used by write_memory to convert typed values (int*, uint*, float, double, string) into little-endian byte arrays using struct.pack.
    def _pack_value(value: Any, value_type: str) -> bytes:
        """Pack value to bytes based on type."""
        formats = {
            "int8": "<b", "uint8": "<B",
            "int16": "<h", "uint16": "<H",
            "int32": "<i", "uint32": "<I",
            "int64": "<q", "uint64": "<Q",
            "float": "<f", "double": "<d"
        }
        fmt = formats.get(value_type)
        if fmt:
            return struct.pack(fmt, value)
        elif value_type == "string":
            return value.encode('utf-8') + b'\x00'
        return struct.pack("<i", int(value))
  • The write_memory tool is listed under memory_operations category in the list_capabilities tool response, indicating its availability.
    "memory_operations": [
        "read_memory", "write_memory", "scan_value", "scan_next",
        "scan_changed", "scan_unchanged", "scan_pattern",
        "get_scan_results", "clear_scan", "list_memory_regions"
  • Docstring defining the input parameters and return type for the write_memory tool, serving as schema documentation.
    """
    Write data to memory address.
    
    Args:
        address: Memory address (hex string like "0x401234")
        data: Data to write (hex string, or value if value_type specified)
        value_type: Type of data ("bytes", "int32", "float", "string", etc.)
    
    Returns:
        Write status.
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool writes data to memory but fails to mention critical details like permissions required, potential side effects (e.g., system instability), error handling, or performance implications. This leaves significant gaps for a mutation tool with safety concerns.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is efficiently structured with a clear purpose statement followed by parameter and return sections. Each sentence adds value without redundancy, though it could be slightly more front-loaded by emphasizing the tool's core action earlier in the text.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (memory writing with potential risks), no annotations, and an output schema that only indicates 'Write status', the description is moderately complete. It covers parameters well but lacks safety warnings, error details, or behavioral context, making it adequate but with clear gaps for informed use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds meaningful context beyond the input schema, which has 0% coverage. It explains that 'address' is a hex string, 'data' can be hex or value-based, and 'value_type' specifies data types with examples. This compensates well for the schema's lack of descriptions, though it could detail more about format constraints.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with a specific verb ('Write') and resource ('memory address'), making it distinct from sibling tools like 'read_memory'. However, it doesn't explicitly differentiate from other memory-related tools beyond the basic function, keeping it from a perfect score.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives, such as 'read_memory' for reading or other memory manipulation tools. It lacks context about prerequisites, dependencies, or typical scenarios, offering only basic parameter information without usage context.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/0xhackerfren/frida-game-hacking-mcp'

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