Skip to content

Lightweight C++ library for external mouse control via DMA. Simple API, no configuration needed. For game development, automation, and research.

License

Notifications You must be signed in to change notification settings

J4sp3rTM/DMA-Mouse-Control

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

DMA Mouse Control Library

A clean, lightweight C++ library for controlling mouse input via DMA (Direct Memory Access) on a remote PC. Designed for game development, automation, and cheat development.

🎯 Features

  • Simple API - Just 3 main functions: Initialize(), MoveMouse(), Shutdown()
  • No Configuration Files - Automatic process and signature discovery
  • Low Latency - Direct memory writes bypass Windows input stack
  • DMA-Based - Uses MemProcFS and FPGA hardware for external memory access
  • Clean Code - Well-documented, easy to integrate into existing projects

πŸ› οΈ Requirements

Hardware

  • DMA Card - PCIe FPGA device (e.g., Squirrel, DMA35, etc.)
  • Two PCs - Main PC (target) and Radar PC (controller with DMA card)

Software

  • Windows 10/11
  • Visual Studio 2022 (or compatible C++ compiler)
  • MemProcFS drivers installed

πŸ“¦ Project Structure

DMA-Mouse-Handler/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ DMAMouse.h          # Library header
β”‚   β”œβ”€β”€ DMAMouse.cpp        # Library implementation
β”‚   β”œβ”€β”€ MouseHandler.cpp    # Target PC program
β”‚   β”œβ”€β”€ Controller.cpp      # Full controller example
β”‚   └── Example.cpp         # Simple usage example
β”œβ”€β”€ bin/                    # Compiled executables and DLLs
β”œβ”€β”€ external/
β”‚   └── memprocfs/         # MemProcFS library files
└── build.bat              # Build script

πŸš€ Quick Start

1. Build the Project

git clone https://github.com/J4sp3rTM/DMA-Mouse-Input-Injection.git
cd DMA-Mouse-Input-Injection
build.bat

2. Run MouseHandler on Target PC

bin\MouseHandler.exe

Note the displayed offset (usually 0x44000).

3. Run Your Controller on Radar PC

bin\Example.exe

πŸ“– Library Usage

Basic Example

#include "DMAMouse.h"

int main() {
    DMAMouse mouse;
    
    // Connect to target process
    if (mouse.Initialize("game.exe")) {
        // Move mouse right 100 pixels
        mouse.MoveMouse(100, 0);
        
        // Move mouse diagonally
        mouse.MoveMouse(50, -50);
    }
    
    mouse.Shutdown();
    return 0;
}

Integration into Your Cheat/Tool

#include "DMAMouse.h"

class MyCheat {
private:
    DMAMouse mouse;
    
public:
    bool Initialize() {
        if (!mouse.Initialize("target.exe")) {
            printf("DMA Init failed: %s\n", mouse.GetLastError());
            return false;
        }
        return true;
    }
    
    void AimAt(int targetX, int targetY, int currentX, int currentY) {
        int deltaX = targetX - currentX;
        int deltaY = targetY - currentY;
        
        // Smooth movement
        while (abs(deltaX) > 1 || abs(deltaY) > 1) {
            int stepX = deltaX / 10;
            int stepY = deltaY / 10;
            
            mouse.MoveMouse(stepX, stepY);
            
            deltaX -= stepX;
            deltaY -= stepY;
            Sleep(1);
        }
    }
};

πŸ”§ API Reference

DMAMouse Class

bool Initialize(const char* processName)

Establishes DMA connection to target process.

  • Parameters: Process name (e.g., "game.exe", "MouseHandler.exe")
  • Returns: true on success, false on failure
  • Example:
    if (!mouse.Initialize("target.exe")) {
        printf("Error: %s\n", mouse.GetLastError());
    }

bool MoveMouse(int deltaX, int deltaY)

Moves mouse by relative delta.

  • Parameters:
    • deltaX: Horizontal pixels (positive = right, negative = left)
    • deltaY: Vertical pixels (positive = down, negative = up)
  • Returns: true on success, false on failure
  • Example:
    mouse.MoveMouse(10, -5);  // Right 10, up 5

bool IsConnected()

Checks if DMA connection is active.

  • Returns: true if initialized and ready

const char* GetLastError()

Gets human-readable error message.

  • Returns: Error description string

void Shutdown()

Closes DMA connection and cleans up resources.

πŸ—οΈ How It Works

Architecture

Radar PC (DMA Card)          Target PC
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Your Cheat     β”‚          β”‚ MouseHandler.exe β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚          β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚  β”‚ DMAMouse  β”‚  β”‚ DMA Read β”‚  β”‚ g_MouseCtrl β”‚ β”‚
β”‚  β”‚ Library   │──┼──────────┼─>β”‚  Structure  β”‚ β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚ DMA Writeβ”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚                 β”‚ <β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜          β”‚  Polls & Moves   β”‚
                             β”‚  Mouse Cursor    β”‚
                             β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Memory Structure

struct MouseControl {
    int deltaX;      // +0x00: X movement
    int deltaY;      // +0x04: Y movement  
    int active;      // +0x08: Command flag
    int signature;   // +0x0C: 0xDEADBEEF
};

Discovery Process

  1. Offset Method (Fast) - Tries known offset 0x44000 first
  2. Pattern Scan (Fallback) - Scans memory for 0xDEADBEEF signature
  3. Verification - Validates structure before use

βš™οΈ Build Configuration

Manual Build Commands

MouseHandler (Target PC):

cl /O2 /EHsc MouseHandler.cpp user32.lib /Fe:MouseHandler.exe

Example (Radar PC):

cl /O2 /EHsc Example.cpp DMAMouse.cpp /I. external\memprocfs\vmm.lib user32.lib /Fe:Example.exe

Compiler Flags

  • /O2 - Optimize for speed
  • /EHsc - Enable C++ exception handling
  • /I. - Include current directory

πŸ› Troubleshooting

"Failed to initialize MemProcFS"

  • Check DMA card is properly connected
  • Verify MemProcFS drivers are installed
  • Run as Administrator

"Target process not found"

  • Ensure MouseHandler.exe is running on target PC
  • Check process name matches exactly
  • Try truncated name if longer than 14 characters

"Could not locate mouse control structure"

  • Verify MouseHandler.exe is the correct version
  • Check if antivirus is interfering
  • Try rebuilding both programs

πŸ“ License

This project is released under MIT License. Free to use, modify, and distribute.

⚠️ Disclaimer

This tool is for educational purposes and legitimate use cases (automation, accessibility, development). Users are responsible for complying with applicable laws and game/software terms of service. The authors are not responsible for misuse.

🀝 Contributing

Pull requests welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Test your changes
  4. Submit a PR with clear description

πŸ“§ Contact

πŸ™ Credits


Star ⭐ this repo if you find it useful!