From 4c0179cbb1ca81989bba2e3f3ae735bb8de5432e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B8=9F=E9=9B=B2?= Date: Wed, 2 Oct 2024 20:50:30 +0800 Subject: [PATCH] Validate after execute --- SPT Fuyu.cpp | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/SPT Fuyu.cpp b/SPT Fuyu.cpp index b695f31..2bf636f 100644 --- a/SPT Fuyu.cpp +++ b/SPT Fuyu.cpp @@ -29,13 +29,50 @@ void CreateRegistryKeyAndFiles(const std::string& installLocation) { CreateDirectoryA(installLocation.c_str(), NULL); CreateDirectoryA((installLocation+ "\\BattlEye").c_str(), NULL); std::ofstream(installLocation + "\\BattlEye\\BEClient_x64.dll").close(); + //This file isn't needed to be created, as it's not exist in EFT live //std::ofstream(installLocation + "\\BattlEye\\BEService_x64.dll").close(); std::ofstream(installLocation + "\\ConsistencyInfo").close(); std::ofstream(installLocation + "\\Uninstall.exe").close(); std::ofstream(installLocation + "\\UnityCrashHandler64.exe").close(); std::ofstream(installLocation + "\\WinPixEventRuntime.dll").close(); } +bool Validate() {//copy from SPT Source + std::wstring registryPath = L"Software\\Wow6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\EscapeFromTarkov"; + int v0 = 0; + try { + HKEY hKey; + if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, registryPath.c_str(), 0, KEY_READ, &hKey) == ERROR_SUCCESS) { + wchar_t installLocation[512]; + DWORD bufferSize = sizeof(installLocation); + if (RegQueryValueExW(hKey, L"InstallLocation", nullptr, nullptr, (LPBYTE)installLocation, &bufferSize) == ERROR_SUCCESS) { + std::wstring v2 = installLocation; + std::vector v4 = { + v2, + v2 + L"\\BattlEye\\BEClient_x64.dll", + v2 + L"\\BattlEye\\BEService_x64.dll", + v2 + L"\\ConsistencyInfo", + v2 + L"\\Uninstall.exe", + v2 + L"\\UnityCrashHandler64.exe" + }; + + v0 = static_cast(v4.size()) - 1; + + for (const auto& value : v4) { + if (std::filesystem::exists(value)) { + --v0; + } + } + } + RegCloseKey(hKey); + } + } + catch (...) { + v0 = -1; + } + + return v0 == 0; +} int main(int argc, char* argv[]) { SetConsoleTitle(L"SPT Fuyu"); @@ -63,8 +100,10 @@ int main(int argc, char* argv[]) { std::string installLocation = filePath; CreateRegistryKeyAndFiles(installLocation); - - std::cout << (isChinese ? "验证执行成功." : "Validation Bypass Succeeded.") << std::endl; + if (Validate()) + std::cout << (isChinese ? "验证执行成功." : "Validation Bypass Succeeded.") << std::endl; + else + std::cout << (isChinese ? "验证执行失败,未知错误." : "Validation Bypass Failed. Unknown Error") << std::endl; system("pause"); return 0; }