added a basic anticheat

This commit is contained in:
Yannik
2023-04-12 21:18:27 +02:00
parent 1b1c72e86a
commit 6e3cebb653
3 changed files with 35 additions and 0 deletions

29
src/anticheat.cs Normal file
View File

@@ -0,0 +1,29 @@
using System.Diagnostics;
using Godot;
public partial class anticheat : Node
{
string[] suspiciousProcesses = { "cheat", "wemod" };
string alertMessage;
string alertTitle;
public override void _Ready()
{
var lang = Json.ParseString(FileAccess.Open("res://assets/lang/en/warnings.json", FileAccess.ModeFlags.Read).GetAsText()).AsGodotDictionary();
alertMessage = lang["cheatalert_message"].ToString();
alertTitle = lang["cheatalert_title"].ToString();
}
public override void _Process(double delta)
{
foreach (Process p in Process.GetProcesses())
foreach (string s in suspiciousProcesses)
{
if (p.ProcessName.Find(s) >= 0) //cheat gets detected
{
GetTree().Paused = true;
OS.Kill(p.Id);
OS.Alert(alertMessage, alertTitle);
GetTree().Paused = false;
}
}
}
}