using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; namespace ET { public class CheckCheatComponentAwakeSystem : AwakeSystem { public override void Awake(CheckCheatComponent self) { //self.timerId = TimerComponent.Instance.NewRepeatedTimer(5 * 1000, self.Check); } } public class CheckCheatComponentDestroySystem : DestroySystem { public override void Destroy(CheckCheatComponent self) { //TimerComponent.Instance.Remove(ref self.timerId); } } public class CheckCheatComponent:Entity { public long timerId; public async void Check() { #if !UNITY_STANDALONE return; #endif bool flag = IsStarted(); if (!flag) return; this.ZoneScene().GetComponent().Session.Send(new C2M_SendQMacro()); //await TimerComponent.Instance.WaitAsync(1000); Log.Error($"作弊"); Game.Close(); #if UNITY_EDITOR UnityEditor.EditorApplication.isPlaying = false; #else // UnityEngine.Application.Quit(); #endif } public static bool IsStarted() { bool flag = true; String com1 = "cmd.exe"; String com2 = " /c tasklist |find \"按键精灵\""; String command = com1 + com2; try { Process ps = Run(com1, com2,@"C:\Windows\System32\",true); string outStr =ps.StandardOutput.ReadLine(); if (outStr != null) { flag = true; } else flag = false; ps.Dispose(); } catch (IOException e) { Log.Error($"{e.StackTrace}"); } return flag; } public static Process Run(string exe, string arguments, string workingDirectory = ".", bool waitExit = false) { try { bool redirectStandardOutput = true; bool redirectStandardError = true; bool useShellExecute = false; redirectStandardOutput = false; redirectStandardError = false; useShellExecute = true; if (waitExit) { redirectStandardOutput = true; redirectStandardError = true; useShellExecute = false; } ProcessStartInfo info = new ProcessStartInfo { FileName = exe, Arguments = arguments, CreateNoWindow = true, WindowStyle = ProcessWindowStyle.Hidden, UseShellExecute = useShellExecute, WorkingDirectory = workingDirectory, RedirectStandardOutput = redirectStandardOutput, RedirectStandardError = redirectStandardError, }; Process process = Process.Start(info); if (waitExit) { process.WaitForExit(); if (process.ExitCode != 0) { } } return process; } catch (Exception e) { throw new Exception($"dir: {Path.GetFullPath(workingDirectory)}, command: {exe} {arguments}", e); } } } }