Table of Contents

Class InjectionDetector

Namespace
CodeStage.AntiCheat.Detectors
Assembly
Build.dll

Allows to detect foreign managed assemblies in your application.

[AddComponentMenu("Code Stage/Anti-Cheat Toolkit/Injection Detector")]
[DisallowMultipleComponent]
[HelpURL("https://docs.codestage.net/actk/manual/detectors.html#injection-detector")]
public class InjectionDetector : ACTkDetectorBase<InjectionDetector>
Inheritance
object
Object
Component
Behaviour
MonoBehaviour
InjectionDetector
Inherited Members

Remarks

Just add it to any GameObject as usual or through the GameObject > Create Other > Code Stage > Anti-Cheat Toolkit menu to get started.
You can use detector completely from inspector without writing any code except the actual reaction on cheating.

Avoid using detectors from code at the Awake phase.

📝 Important Notes:
• Make sure you've checked the "Enable Injection Detector" option at the Tools > Code Stage > Anti-Cheat Toolkit > Settings window before using detector at runtime.
• Always test detector on the target platform before releasing your application to the public.
• It may detect some external assemblies as foreign, thus make sure you've added all external assemblies your application uses to the Whitelist (see section "Whitelist management" of the User Manual for details).
• Disabled in Editor because of specific assemblies causing false positives. Use ACTK_INJECTION_DEBUG symbol to force it in Editor.
• Only detects managed assembly injections (Mono/.NET assemblies). Native (unmanaged) code injections are NOT detected - they operate at a lower level and require additional protection mechanisms.

⚠️ Warning: Only Standalone and Android platforms with Mono scripting backend are supported.

// Basic usage - start detection with callback
void Start()
{
    if (InjectionDetector.IsSupported)
    {
        InjectionDetector.StartDetection(OnInjectionDetected);
        Debug.Log("Injection detection started");
    }
    else
    {
        Debug.LogWarning("Injection detector not supported on this platform (IL2CPP)");
    }
}

private void OnInjectionDetected()
{
    Debug.Log("Injection detected!");

    // Get detailed detection info
    Debug.Log($"Detection details: {InjectionDetector.Instance.LastDetectionInfo}");

    // Handle the detection - ban player, show warning, etc.
}
// Advanced usage with detailed callback
void Start()
{
    // Start with detailed callback that provides injection cause
    InjectionDetector.StartDetection(OnInjectionDetectedWithCause);
}

private void OnInjectionDetectedWithCause(string cause)
{
    Debug.Log($"Injection detected! Cause: {cause}");

    // or get detailed detection info (contains same reason as callback parameter)
    Debug.Log($"Detection details: {InjectionDetector.Instance.LastDetectionInfo}");
}

Fields

ComponentName

public const string ComponentName = "Injection Detector"

Field Value

string

Properties

LastDetectionInfo

Holds detailed information about latest triggered detection.

public InjectionDetectionInfo LastDetectionInfo { get; }

Property Value

InjectionDetectionInfo

Remarks

Provides information about what triggered the injection detection, typically the name of the injected assembly or the detection cause.

Methods

AddToSceneOrGetExisting()

public static InjectionDetector AddToSceneOrGetExisting()

Returns

InjectionDetector

Dispose()

public static void Dispose()

StartDetection()

public static void StartDetection()

StartDetection(Action<string>)

public static void StartDetection(Action<string> callback)

Parameters

callback Action<string>

StopDetection()

public static void StopDetection()