From a7a0f03e5466f3993401f5a1e85abaf00e548abc Mon Sep 17 00:00:00 2001 From: m Date: Sun, 14 Aug 2022 16:56:23 -0500 Subject: [PATCH 1/3] warn if steam registry doesn't exists --- src/client/component/auth.cpp | 1 - src/client/component/exception.cpp | 2 +- src/client/component/system_check.cpp | 5 ++--- src/client/loader/loader.cpp | 2 +- src/client/main.cpp | 27 ++++++++++++++++++++++++++- src/client/std_include.hpp | 4 ++++ 6 files changed, 34 insertions(+), 7 deletions(-) diff --git a/src/client/component/auth.cpp b/src/client/component/auth.cpp index 268d23ab..3ba4a4cd 100644 --- a/src/client/component/auth.cpp +++ b/src/client/component/auth.cpp @@ -162,7 +162,6 @@ namespace auth if (xuid != key.get_hash()) { - //MessageBoxA(nullptr, steam_id.data(), std::to_string(key.get_hash()).data(), 0); network::send(*from, "error", utils::string::va("XUID doesn't match the certificate: %llX != %llX", xuid, key.get_hash()), '\n'); return; diff --git a/src/client/component/exception.cpp b/src/client/component/exception.cpp index 598473ad..0cba305a 100644 --- a/src/client/component/exception.cpp +++ b/src/client/component/exception.cpp @@ -101,7 +101,7 @@ namespace exception utils::thread::suspend_other_threads(); show_mouse_cursor(); - MessageBoxA(nullptr, error_str.data(), "H1-Mod ERROR", MB_ICONERROR); + MSG_BOX_ERROR(error_str.data()); TerminateProcess(GetCurrentProcess(), exception_data.code); } diff --git a/src/client/component/system_check.cpp b/src/client/component/system_check.cpp index 794bf375..471ae5e7 100644 --- a/src/client/component/system_check.cpp +++ b/src/client/component/system_check.cpp @@ -90,9 +90,8 @@ namespace system_check if (!is_valid()) { - MessageBoxA(nullptr, "Your game files are outdated or unsupported.\n" - "Please get the latest officially supported Call of Duty: Modern Warfare Remastered files, or you will get random crashes and issues.", - "Invalid game files!", MB_ICONINFORMATION); + MSG_BOX_INFO("Your game files are outdated or unsupported.\n" + "Please get the latest officially supported Call of Duty: Modern Warfare Remastered files, or you will get random crashes and issues."); } } }; diff --git a/src/client/loader/loader.cpp b/src/client/loader/loader.cpp index 4ec12c7c..09dfde68 100644 --- a/src/client/loader/loader.cpp +++ b/src/client/loader/loader.cpp @@ -152,7 +152,7 @@ void loader::load_exception_table(const utils::nt::library& target, const utils: if (!RtlAddFunctionTable(function_list, entry_count, DWORD64(target.get_ptr()))) { - MessageBoxA(nullptr, "Setting exception handlers failed.", "Error", MB_OK | MB_ICONERROR); + MSG_BOX_ERROR("Setting exception handlers failed."); } { diff --git a/src/client/main.cpp b/src/client/main.cpp index 1c078970..4a1a0752 100644 --- a/src/client/main.cpp +++ b/src/client/main.cpp @@ -81,6 +81,26 @@ void get_aslr_patched_binary(std::string* binary, std::string* data) *binary = patched_binary; } +bool is_steam_registry_found() +{ + static bool is_steam_installed = false; + static bool is_steam_installed_set = false; + + if (!is_steam_installed_set) + { + HKEY key = nullptr; + if (RegOpenKeyExA(HKEY_CURRENT_USER, "Software\\Valve\\Steam", 0, KEY_ALL_ACCESS, &key) == ERROR_SUCCESS) + { + is_steam_installed = true; + RegCloseKey(key); + } + + is_steam_installed_set = true; + } + + return is_steam_installed; +} + FARPROC load_binary(const launcher::mode mode, uint64_t* base_address) { loader loader; @@ -91,6 +111,11 @@ FARPROC load_binary(const launcher::mode mode, uint64_t* base_address) if (library == "steam_api64.dll" && function != "SteamAPI_GetSteamInstallPath") // Arxan requires one valid steam api import - maybe SteamAPI_Shutdown is better? { + if (!is_steam_registry_found()) + { + MSG_BOX_WARN("Could not find Steam in the registry. If Steam is not installed, you must install it for H1-Mod to work."); + } + return self.get_proc(function); } else if (function == "ExitProcess") @@ -234,7 +259,7 @@ int main() } catch (std::exception& e) { - MessageBoxA(nullptr, e.what(), "ERROR", MB_ICONERROR); + MSG_BOX_ERROR(e.what()); return 1; } } diff --git a/src/client/std_include.hpp b/src/client/std_include.hpp index e43275c3..4b50b32a 100644 --- a/src/client/std_include.hpp +++ b/src/client/std_include.hpp @@ -59,6 +59,10 @@ #undef min #endif +#define MSG_BOX_INFO(message) MessageBoxA(nullptr, message, "H1-Mod: WARNING", MB_ICONINFORMATION); +#define MSG_BOX_WARN(message) MessageBoxA(nullptr, message, "H1-Mod: WARNING", MB_ICONWARNING); +#define MSG_BOX_ERROR(message) MessageBoxA(nullptr, message, "H1-Mod: ERROR", MB_ICONERROR); + #include #include #include From ead98780f7b17920653ea451d89cdc35ba91c622 Mon Sep 17 00:00:00 2001 From: m Date: Sun, 14 Aug 2022 17:01:02 -0500 Subject: [PATCH 2/3] only warn the user once --- src/client/main.cpp | 35 +++++++++++++---------------------- 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/src/client/main.cpp b/src/client/main.cpp index 4a1a0752..c1486f82 100644 --- a/src/client/main.cpp +++ b/src/client/main.cpp @@ -81,26 +81,6 @@ void get_aslr_patched_binary(std::string* binary, std::string* data) *binary = patched_binary; } -bool is_steam_registry_found() -{ - static bool is_steam_installed = false; - static bool is_steam_installed_set = false; - - if (!is_steam_installed_set) - { - HKEY key = nullptr; - if (RegOpenKeyExA(HKEY_CURRENT_USER, "Software\\Valve\\Steam", 0, KEY_ALL_ACCESS, &key) == ERROR_SUCCESS) - { - is_steam_installed = true; - RegCloseKey(key); - } - - is_steam_installed_set = true; - } - - return is_steam_installed; -} - FARPROC load_binary(const launcher::mode mode, uint64_t* base_address) { loader loader; @@ -111,9 +91,20 @@ FARPROC load_binary(const launcher::mode mode, uint64_t* base_address) if (library == "steam_api64.dll" && function != "SteamAPI_GetSteamInstallPath") // Arxan requires one valid steam api import - maybe SteamAPI_Shutdown is better? { - if (!is_steam_registry_found()) + static bool check_for_steam_install = false; + if (!check_for_steam_install) { - MSG_BOX_WARN("Could not find Steam in the registry. If Steam is not installed, you must install it for H1-Mod to work."); + HKEY key; + if (RegOpenKeyExA(HKEY_CURRENT_USER, "Software\\Valve\\Steam", 0, KEY_ALL_ACCESS, &key) == ERROR_SUCCESS) + { + RegCloseKey(key); + } + else + { + MSG_BOX_WARN("Could not find Steam in the registry. If Steam is not installed, you must install it for H1-Mod to work."); + } + + check_for_steam_install = true; } return self.get_proc(function); From dc9a5b49f8695024906f6d286cc848228fc61bbc Mon Sep 17 00:00:00 2001 From: m Date: Tue, 16 Aug 2022 01:30:44 -0500 Subject: [PATCH 3/3] change macro [skip ci] --- src/client/std_include.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/std_include.hpp b/src/client/std_include.hpp index 4b50b32a..2f947f9c 100644 --- a/src/client/std_include.hpp +++ b/src/client/std_include.hpp @@ -59,7 +59,7 @@ #undef min #endif -#define MSG_BOX_INFO(message) MessageBoxA(nullptr, message, "H1-Mod: WARNING", MB_ICONINFORMATION); +#define MSG_BOX_INFO(message) MessageBoxA(nullptr, message, "H1-Mod: INFORMATION", MB_ICONINFORMATION); #define MSG_BOX_WARN(message) MessageBoxA(nullptr, message, "H1-Mod: WARNING", MB_ICONWARNING); #define MSG_BOX_ERROR(message) MessageBoxA(nullptr, message, "H1-Mod: ERROR", MB_ICONERROR);