Skip to main content
Glama
cbxss
by cbxss

memory_write

Write hex bytes to a memory address on Android devices for runtime patching in mobile security testing.

Instructions

Write bytes to memory address (for patching)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
addressYesMemory address (e.g., '0x12345678')
hex_bytesYesHex bytes to write (e.g., 'deadbeef')

Implementation Reference

  • The memory_write handler function that executes the write logic: converts hex string to bytes, uses Frida's Memory.protect() and Memory.writeByteArray() to write to the target address, and returns success/failure via a synchronous Frida script.
    def memory_write(address: str, hex_bytes: str) -> dict:
        """Write bytes to memory address."""
        js_code = '''
            var addr = ptr(''' + json.dumps(address) + ''');
            var bytes = ''' + json.dumps(hex_bytes) + ''';
            var arr = [];
            for (var i = 0; i < bytes.length; i += 2) {
                arr.push(parseInt(bytes.substr(i, 2), 16));
            }
            try {
                Memory.protect(addr, arr.length, 'rwx');
                Memory.writeByteArray(addr, arr);
                send({success: true, address: addr.toString(), bytes_written: arr.length});
            } catch(e) {
                send({success: false, error: e.message});
            }
        '''
        return run_script_sync(js_code)
  • The tool registration/schema definition for memory_write, declaring name, description ('Write bytes to memory address (for patching)'), and inputSchema with required 'address' (string) and 'hex_bytes' (string) parameters.
    Tool(
        name="memory_write",
        description="Write bytes to memory address (for patching)",
        inputSchema={
            "type": "object",
            "properties": {
                "address": {"type": "string", "description": "Memory address (e.g., '0x12345678')"},
                "hex_bytes": {"type": "string", "description": "Hex bytes to write (e.g., 'deadbeef')"},
            },
            "required": ["address", "hex_bytes"],
        },
    ),
  • The input schema for memory_write defining two required parameters: address (hex string like '0x12345678') and hex_bytes (hex bytes like 'deadbeef').
    Tool(
        name="memory_write",
        description="Write bytes to memory address (for patching)",
        inputSchema={
            "type": "object",
            "properties": {
                "address": {"type": "string", "description": "Memory address (e.g., '0x12345678')"},
                "hex_bytes": {"type": "string", "description": "Hex bytes to write (e.g., 'deadbeef')"},
            },
            "required": ["address", "hex_bytes"],
        },
    ),
  • The dispatcher in call_tool() that routes 'memory_write' requests to memory.memory_write() with address and hex_bytes arguments.
    elif name == "memory_write":
        return memory.memory_write(arguments["address"], arguments["hex_bytes"])
Behavior2/5

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

Without annotations, description must disclose behavioral traits. It only states 'for patching' but does not mention side effects (e.g., process crash), required permissions, or that it is a destructive operation.

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

Conciseness5/5

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

Single sentence, front-loaded with verb and resource, no fluff. Every word earns its place.

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

Completeness2/5

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

Despite full schema coverage, the tool is a write/modify operation with no output schema. Description should include safety warnings or behavior expectations, which are missing.

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

Parameters3/5

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

Input schema has 100% description coverage for both parameters. Description adds no additional semantics beyond the schema, so baseline score 3 is appropriate.

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

Purpose5/5

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

Description clearly states it writes bytes to a memory address for patching, using specific verb and resource. Easily distinguished from sibling tools like memory_read or memory_search.

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?

No explicit guidance on when to use this tool versus alternatives. Lacks context about prerequisites like connection or permissions, and what distinguishes it from other modification tools.

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/cbxss/frida-mcp'

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