Skip to main content
Glama

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

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.

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