Skip to main content
Glama
0xhackerfren

Frida Game Hacking MCP

by 0xhackerfren

screenshot_screen

Capture game screenshots for analysis by taking full-screen or region-specific images, saving as PNG files or returning base64 data for reverse engineering workflows.

Instructions

Take a screenshot of the entire screen or a region.

Args:
    save_path: Optional path to save the screenshot (PNG). If empty, returns base64.
    region: Optional [x, y, width, height] to capture specific region.

Returns:
    Screenshot info with base64 data or saved file path.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
save_pathNo
regionNo

Implementation Reference

  • The core handler function for the 'screenshot_screen' tool. Captures screenshot of full screen or region using Windows DC APIs (GetDesktopWindow, BitBlt), converts BMP to PIL Image, and returns base64 PNG data or saves to file. Requires pywin32 and pillow.
    @mcp.tool()
    def screenshot_screen(save_path: str = "", region: List[int] = None) -> Dict[str, Any]:
        """
        Take a screenshot of the entire screen or a region.
        
        Args:
            save_path: Optional path to save the screenshot (PNG). If empty, returns base64.
            region: Optional [x, y, width, height] to capture specific region.
        
        Returns:
            Screenshot info with base64 data or saved file path.
        """
        if not SCREENSHOT_AVAILABLE:
            return {"error": "Screenshot support not available. Install: pip install pywin32 pillow"}
        
        try:
            # Get screen dimensions
            if region:
                x, y, width, height = region
            else:
                x, y = 0, 0
                width = ctypes.windll.user32.GetSystemMetrics(0)
                height = ctypes.windll.user32.GetSystemMetrics(1)
            
            # Capture screen
            hwnd = win32gui.GetDesktopWindow()
            hwnd_dc = win32gui.GetWindowDC(hwnd)
            mfc_dc = win32ui.CreateDCFromHandle(hwnd_dc)
            save_dc = mfc_dc.CreateCompatibleDC()
            
            bitmap = win32ui.CreateBitmap()
            bitmap.CreateCompatibleBitmap(mfc_dc, width, height)
            save_dc.SelectObject(bitmap)
            
            save_dc.BitBlt((0, 0), (width, height), mfc_dc, (x, y), win32con.SRCCOPY)
            
            # Convert to PIL Image
            bmp_info = bitmap.GetInfo()
            bmp_str = bitmap.GetBitmapBits(True)
            
            img = Image.frombuffer(
                'RGB',
                (bmp_info['bmWidth'], bmp_info['bmHeight']),
                bmp_str, 'raw', 'BGRX', 0, 1
            )
            
            # Cleanup
            win32gui.DeleteObject(bitmap.GetHandle())
            save_dc.DeleteDC()
            mfc_dc.DeleteDC()
            win32gui.ReleaseDC(hwnd, hwnd_dc)
            
            # Save or return base64
            if save_path:
                img.save(save_path, 'PNG')
                return {
                    "success": True,
                    "path": save_path,
                    "width": width,
                    "height": height
                }
            else:
                buffer = io.BytesIO()
                img.save(buffer, format='PNG')
                img_base64 = base64.b64encode(buffer.getvalue()).decode('utf-8')
                
                return {
                    "success": True,
                    "width": width,
                    "height": height,
                    "image_base64": img_base64,
                    "format": "png"
                }
        
        except Exception as e:
            return {"error": f"Screenshot failed: {str(e)}"}
  • The tool is listed under 'window_interaction' category in the list_capabilities tool, indicating its registration in the MCP server.
    "window_interaction": [
        "list_windows", "screenshot_window", "screenshot_screen",
        "send_key_to_window", "focus_window"
  • Imports and flag for Windows screenshot support (pywin32, pillow), required by the screenshot tools.
    # Screenshot support (Windows)
    SCREENSHOT_AVAILABLE = False
    try:
        import ctypes
        from ctypes import wintypes
        import win32gui
        import win32ui
        import win32con
        import win32process
        from PIL import Image
        SCREENSHOT_AVAILABLE = True
    except ImportError:
        pass

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