Skip to main content
Glama
0xhackerfren

Frida Game Hacking MCP

by 0xhackerfren

scan_changed

Identifies memory addresses where values have changed since the previous scan, enabling detection of dynamic game variables for reverse engineering and modification.

Instructions

Find addresses where value has changed since last scan.

Returns:
    Number of changed addresses.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • MCP tool handler implementing scan_changed: filters scan results to addresses where value changed since last scan using batched Frida Memory.readByteArray and comparison to stored last_values. Updates scan_state.results and last_values.
    @mcp.tool()
    def scan_changed() -> Dict[str, Any]:
        """
        Find addresses where value has changed since last scan.
        
        Returns:
            Number of changed addresses.
        """
        global _session
        
        if not _session.is_attached():
            return {"error": "Not attached. Use attach() first."}
        
        if not _session.scan_state.scan_active:
            return {"error": "No active scan. Use scan_value() first."}
        
        try:
            value_type = _session.scan_state.value_type
            value_size = _get_value_size(value_type)
            
            addresses = [a for a in _session.scan_state.results if a in _session.scan_state.last_values]
            if not addresses:
                return {"success": True, "remaining": 0}
            
            expected_map = {}
            for addr in addresses:
                last_val = _session.scan_state.last_values[addr]
                if value_type == "string":
                    expected_map[addr] = str(last_val).encode('utf-8').hex()
                else:
                    expected_map[addr] = _pack_value(last_val, value_type).hex()
            
            batch_size = 1000
            new_results = []
            new_last_values = {}
            
            for batch_start in range(0, len(addresses), batch_size):
                batch = addresses[batch_start:batch_start + batch_size]
                addr_expected = ", ".join(f'["{hex(a)}", "{expected_map[a]}"]' for a in batch)
                
                script_code = f"""
                var pairs = [{addr_expected}];
                var size = {value_size};
                var changed = [];
                
                for (var i = 0; i < pairs.length; i++) {{
                    try {{
                        var data = Memory.readByteArray(ptr(pairs[i][0]), size);
                        var hex = '';
                        var bytes = new Uint8Array(data);
                        for (var j = 0; j < bytes.length; j++) {{
                            hex += ('0' + bytes[j].toString(16)).slice(-2);
                        }}
                        if (hex !== pairs[i][1]) {{
                            changed.push({{address: pairs[i][0], hex: hex}});
                        }}
                    }} catch (e) {{ }}
                }}
                send(JSON.stringify(changed));
                """
                
                result_data = []
                def on_message(message, data):
                    if message['type'] == 'send':
                        result_data.append(message['payload'])
                
                script = _session.session.create_script(script_code)
                script.on('message', on_message)
                script.load()
                script.unload()
                
                if result_data:
                    import json
                    changed = json.loads(result_data[0])
                    for c in changed:
                        addr = int(c['address'], 16)
                        try:
                            current_value = _unpack_value(bytes.fromhex(c['hex']), value_type)
                            new_results.append(addr)
                            new_last_values[addr] = current_value
                        except:
                            pass
            
            _session.scan_state.results = new_results
            _session.scan_state.last_values = new_last_values
            
            return {"success": True, "remaining": len(new_results)}
        
        except Exception as e:
            return {"error": f"Scan changed failed: {str(e)}"}
  • Dataclass managing global scan state (results list, last_values dict, value_type, active flag) used by scan_changed and related tools.
    @dataclass
    class ScanState:
        """Tracks memory scan state for Cheat Engine-style scanning."""
        value_type: str = ""
        results: List[int] = field(default_factory=list)
        last_values: Dict[int, Any] = field(default_factory=dict)
        scan_active: bool = False
  • Helper to unpack raw bytes from memory read into typed value (int/float/string) for scan_changed value comparisons.
    def _unpack_value(data: bytes, value_type: str) -> Any:
        """Unpack bytes to value 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.unpack(fmt, data)[0]
        elif value_type == "string":
            return data.split(b'\x00')[0].decode('utf-8', errors='replace')
        return struct.unpack("<i", data)[0]
  • Helper returning byte size for value_type used in scan_changed for Memory.readByteArray size.
    def _get_value_size(value_type: str) -> int:
        """Get byte size for value type."""
        sizes = {
            "int8": 1, "uint8": 1,
            "int16": 2, "uint16": 2,
            "int32": 4, "uint32": 4,
            "int64": 8, "uint64": 8,
            "float": 4, "double": 8
        }
        return sizes.get(value_type, 4)
  • Tool name 'scan_changed' listed in memory_operations category within list_capabilities tool response.
    "memory_operations": [
        "read_memory", "write_memory", "scan_value", "scan_next",
        "scan_changed", "scan_unchanged", "scan_pattern",
        "get_scan_results", "clear_scan", "list_memory_regions"
Behavior2/5

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

No annotations are provided, so the description must fully disclose behavioral traits. It mentions the return value ('Number of changed addresses'), which is helpful, but fails to describe what 'last scan' refers to, whether this is a read-only operation, or any side effects. For a tool with zero annotation coverage, this is insufficient.

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 brief and front-loaded, with two sentences that directly state the purpose and return value. There is no wasted text, making it efficient. However, it could be slightly more structured (e.g., separating purpose and returns more clearly), preventing a perfect score.

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 has 0 parameters, 100% schema coverage, and an output schema (implied by 'Returns'), the description is adequate but minimal. It explains the purpose and return value, yet lacks context about dependencies (e.g., requiring a previous scan) or behavioral details, making it only minimally viable.

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 input schema has 0 parameters with 100% coverage, so no parameter documentation is needed. The description does not add parameter details, which is appropriate. A baseline of 4 is assigned as it meets expectations for a parameterless tool.

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: 'Find addresses where value has changed since last scan.' This specifies the verb ('Find') and resource ('addresses where value has changed'), making it understandable. However, it does not explicitly differentiate from sibling tools like 'scan_unchanged' or 'scan_next', which prevents a score of 5.

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. It does not mention prerequisites (e.g., needing a prior scan), exclusions, or comparisons to siblings like 'scan_unchanged' or 'scan_pattern'. This lack of context leaves the agent without usage direction.

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