0
0
mirror of https://github.com/sp-tarkov/modules.git synced 2025-02-13 09:50:43 -05:00
modules/project/Aki.Core/Utils/ValidationUtil.cs
DrakiaXYZ efa7a175c3 Exit if the user has deleted the BepInEx/plugins/spt folder (!109)
Added as a check in the PrePatch, because while users delete `BepInEx/plugins/spt` often, it would be uncommon for them to also delete the prepatcher

No idea why there's a second commit in this PR, it doesn't actually change anything. Just Git Things™

Co-authored-by: Terkoiz <terkoiz@spt.dev>
Co-authored-by: DrakiaXYZ <565558+TheDgtl@users.noreply.github.com>
Reviewed-on: SPT-AKI/Modules#109
Co-authored-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
Co-committed-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
2024-04-20 21:54:26 +01:00

58 lines
1.9 KiB
C#

using Aki.Common.Utils;
using Microsoft.Win32;
using System.IO;
namespace Aki.Core.Utils
{
public static class ValidationUtil
{
public static bool Validate()
{
var c0 = @"Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\EscapeFromTarkov";
var v0 = 0;
try
{
var v1 = Registry.LocalMachine.OpenSubKey(c0, false).GetValue("InstallLocation");
var v2 = (v1 != null) ? v1.ToString() : string.Empty;
var v3 = new DirectoryInfo(v2);
var v4 = new FileSystemInfo[]
{
v3,
new FileInfo(Path.Combine(v2, @"BattlEye\BEClient_x64.dll")),
new FileInfo(Path.Combine(v2, @"BattlEye\BEService_x64.exe")),
new FileInfo(Path.Combine(v2, "ConsistencyInfo")),
new FileInfo(Path.Combine(v2, "Uninstall.exe")),
new FileInfo(Path.Combine(v2, "UnityCrashHandler64.exe"))
};
ServerLog.Debug("Aki.Core", Gfs(v2, "UnityCrashHandler64.exe")?.Length.ToString() ?? "0");
ServerLog.Debug("Aki.Core", Gfs(v2, "Uninstall.exe")?.Length.ToString() ?? "0");
ServerLog.Debug("Aki.Core", Gfs(v2, "Register.bat")?.Length.ToString() ?? "0");
v0 = v4.Length - 1;
foreach (var value in v4)
{
if (File.Exists(value.FullName))
{
--v0;
}
}
}
catch
{
v0 = -1;
}
return v0 == 0;
}
private static FileInfo Gfs(string p, string f)
{
var a = Path.Combine(p, f);
return File.Exists(a) ? new FileInfo(a) : null;
}
}
}