# Unity Anti Mod Loader Framework A lightweight, zero-dependency C# security utility for Unity games designed to detect unauthorized mod loader frameworks (**MelonLoader** and **BepInEx**) using fast filesystem verification (`File.Exists` & `Directory.Exists`) and DLL proxy heuristic checks. --- ## Features - **MelonLoader Detection**: - Detects core directory structures (`MelonLoader/`, `MelonLoader/Dependencies/`, `Mods/`, `UserLibs/`). - Scans for bootstrap DLLs and loader hooks (`version.dll`, `winmm.dll`, `MelonLoader.dll`, `Bootstrap.dll`). - **BepInEx Detection**: - Detects core directory structures (`BepInEx/`, `BepInEx/core/`, `BepInEx/plugins/`, `BepInEx/patchers/`). - Scans for Unity Doorstop files and injection proxies (`winhttp.dll`, `doorstop_config.ini`, `BepInEx.Core.dll`, `0Harmony.dll`). - **Zero Overhead**: Synchronous filesystem checks executed at startup before scene load with 0 runtime GC pressure. - **Cross-Platform Compatibility**: Fully compatible with Unity Standalone Windows (x86 / x64), macOS, and Linux builds. --- ## Detection Mechanism Mod loaders for Unity games rely on DLL proxying / hijacking to intercept the engine runtime before `UnityPlayer.dll` initializes: 1. **BepInEx**: Uses Unity Doorstop (`winhttp.dll` or `doorstop_config.ini`) and places assemblies inside the `BepInEx/` directory. 2. **MelonLoader**: Uses native proxy DLLs (`version.dll` or `winmm.dll`) and initializes modules inside `MelonLoader/Dependencies/`. `Unity-AntiModLoader` inspects the active game execution root using `Application.dataPath` parent resolution and queries standard path signatures. --- ## Quick Start ### Basic Check ```csharp using UnityEngine; using UnityAntiModLoader; public class SecurityBootstrapper : MonoBehaviour { private void Awake() { if (AntiModLoader.IsAnyModLoaderPresent()) { Debug.LogError("[Security] Mod loader detected! Terminating game."); Application.Quit(); } } } ``` ### Detailed Detection Results ```csharp using System.Collections.Generic; using UnityEngine; using UnityAntiModLoader; using UnityAntiModLoader.Models; public class GameSecurityManager : MonoBehaviour { private void Start() { List results = AntiModLoader.RunFullCheck(); foreach (ModDetectionResult result in results) { Debug.LogWarning($"Detected Framework: {result.FrameworkName}"); Debug.LogWarning($"Severity Level: {result.Severity}"); foreach (string artifact in result.DetectedArtifacts) { Debug.LogWarning($" -> Artifact: {artifact}"); } } } } ``` --- ## Project Structure ``` src/ ├── Detectors/ │ ├── BepInExDetector.cs # BepInEx files, doorstop configs & proxy DLL checks │ └── MelonLoaderDetector.cs # MelonLoader directory & version.dll checks ├── Example/ │ └── ModDetectionListener.cs # Example MonoBehaviour integration & auto-quit ├── Models/ │ └── ModDetectionResult.cs # Detection result data container & severity enum └── AntiModLoader.cs # Primary entry point & game root resolver ``` --- ## License Released under the [MIT License](LICENSE).