Example #1
0
        }                                       // prevents direct instantiation

        private InjectionDetector StartDetectionInternal(InjectionDetectedEventHandler callback)
        {
            if (isRunning)
            {
                Debug.LogWarning(FinalLogPrefix + "already running!", this);
                return(this);
            }

            if (!enabled)
            {
                Debug.LogWarning(FinalLogPrefix + "disabled but StartDetection still called from somewhere (see stack trace for this message)!", this);
                return(this);
            }

            if ((CheatDetected != null || callback != null) && detectionEventHasListener)
            {
                Debug.LogWarning(FinalLogPrefix + "has properly configured Detection Event in the inspector, but still get started with Action callback. Both Action and Detection Event will be called on detection. Are you sure you wish to do this?", this);
            }

            if (CheatDetected == null && callback == null && !detectionEventHasListener)
            {
                Debug.LogWarning(FinalLogPrefix + "was started without any callbacks. Please configure Detection Event in the inspector, or pass the callback Action to the StartDetection method.", this);
                enabled = false;
                return(this);
            }

            CheatDetected += callback;
            started        = true;
            isRunning      = true;

            if (Application.isEditor)
            {
                Debug.Log(FinalLogPrefix + "does not work in Unity Editor.", this);
                return(this);
            }

            if (allowedAssemblies == null)
            {
                LoadAndParseAllowedAssemblies();
            }

            if (signaturesAreMissing)
            {
                OnCheatingDetected("signatures are missing (did you enable " + ComponentName + "?)");
            }
            else if (signaturesAreNotGenuine)
            {
                OnCheatingDetected("signatures are not genuine or damaged");
                return(this);
            }

            string cause;

            if (!FindInjectionInCurrentAssemblies(out cause))
            {
                // listening for new assemblies
                AppDomain.CurrentDomain.AssemblyLoad += OnNewAssemblyLoaded;
            }
            else
            {
                OnCheatingDetected(cause);
            }

            return(this);
        }
Example #2
0
 /// <summary>
 /// Starts foreign assemblies injection detection with specified callback containing string argument.<br/>
 /// Assembly name will be passed to the argument if possible. Otherwise another cause of the detection will be passed.
 /// </summary>
 /// If you have detector in scene make sure it has empty Detection Event.<br/>
 /// Creates a new detector instance if it doesn't exists in scene.
 /// <param name="callback">Method to call after detection.</param>
 public static InjectionDetector StartDetection(InjectionDetectedEventHandler callback)
 {
     return(GetOrCreateInstance.StartDetectionInternal(callback));
 }