list_memory_regions
Identify and analyze memory regions in a process to support game hacking and reverse engineering tasks. Filter results by protection flags like read, write, or execute permissions.
Instructions
List memory regions in the process.
Args:
protection: Filter by protection (e.g., "r-x", "rw-", "rwx")
Returns:
List of memory regions with base, size, and protection.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| protection | No |
Implementation Reference
- The primary handler function for the 'list_memory_regions' MCP tool. It injects Frida JavaScript to enumerate all memory ranges using Process.enumerateRanges('r--'), maps them to JSON with base, size, protection, and file path, sends back via send(), parses, optionally filters by protection string, limits to 100, and returns count and regions list. Requires an attached Frida session.def list_memory_regions(protection: str = "") -> Dict[str, Any]: """ List memory regions in the process. Args: protection: Filter by protection (e.g., "r-x", "rw-", "rwx") Returns: List of memory regions with base, size, and protection. """ global _session if not _session.is_attached(): return {"error": "Not attached. Use attach() first."} try: script_code = """ var ranges = Process.enumerateRanges('r--'); var result = ranges.map(function(r) { return { base: r.base.toString(), size: r.size, protection: r.protection, file: r.file ? r.file.path : null }; }); send(JSON.stringify(result)); """ 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 not result_data: return {"error": "Failed to enumerate regions"} import json regions = json.loads(result_data[0]) if protection: regions = [r for r in regions if protection in r['protection']] return {"count": len(regions), "regions": regions[:100]} except Exception as e: return {"error": f"Failed to enumerate regions: {str(e)}"}