Skip to content

Commit

Permalink
Add first pass at checks for cheat engine
Browse files Browse the repository at this point in the history
  • Loading branch information
GrantBartlett committed May 27, 2018
1 parent a1146d1 commit f7ce8e8
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions DXMainClient/DXGUI/Multiplayer/CnCNet/CnCNetLobby.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
using Rampastring.XNAUI.XNAControls;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Threading;

namespace DTAClient.DXGUI.Multiplayer.CnCNet
{
Expand Down Expand Up @@ -244,6 +247,11 @@ public override void Initialize()

WindowManager.CenterControlOnScreen(this);

BackgroundWorker cheatEngineWorker = new BackgroundWorker();
cheatEngineWorker.DoWork += CheatEngineWatchEvent;
cheatEngineWorker.WorkerReportsProgress = true;
cheatEngineWorker.RunWorkerAsync();

PostUIInit();
}

Expand Down Expand Up @@ -365,6 +373,55 @@ private void PostUIInit()
GameProcessLogic.GameProcessExited += SharedUILogic_GameProcessExited;
}

private void CheatEngineWatchEvent(object sender, DoWorkEventArgs e)
{
while (true)
{
BackgroundWorker worker = sender as BackgroundWorker;
int delay = 5000; // 5 seconds
while (!worker.CancellationPending)
{
Process[] processlist = Process.GetProcesses();
foreach (Process process in processlist)
{
if (process.ProcessName.Contains("cheatengine") ||
process.MainWindowTitle.ToLower().Contains("cheat engine") ||
process.MainWindowHandle.ToString().ToLower().Contains("cheat engine")
)
{
KillGameInstance();
}
}

Thread.Sleep(delay);
}
}
}

private void KillGameInstance()
{
try
{
string gameExecutableName = ClientConfiguration.Instance.GetOperatingSystemVersion() == OSVersion.UNIX ?
ClientConfiguration.Instance.GetUnixGameExecutableName() :
ClientConfiguration.Instance.GetGameExecutableName();

gameExecutableName = gameExecutableName.Replace(".exe", "");

Process[] processlist = Process.GetProcesses();
foreach (Process process in processlist)
{
if (process.ProcessName.Contains(gameExecutableName))
{
process.Kill();
}
}
}
catch
{
}
}

/// <summary>
/// Displays a message when the IRC server has informed that the local user
/// has been banned from a channel that they're attempting to join.
Expand Down

0 comments on commit f7ce8e8

Please sign in to comment.