only warn the user once

This commit is contained in:
m 2022-08-14 17:01:02 -05:00
parent a7a0f03e54
commit ead98780f7

View File

@ -81,26 +81,6 @@ void get_aslr_patched_binary(std::string* binary, std::string* data)
*binary = patched_binary; *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) FARPROC load_binary(const launcher::mode mode, uint64_t* base_address)
{ {
loader loader; loader loader;
@ -111,11 +91,22 @@ FARPROC load_binary(const launcher::mode mode, uint64_t* base_address)
if (library == "steam_api64.dll" if (library == "steam_api64.dll"
&& function != "SteamAPI_GetSteamInstallPath") // Arxan requires one valid steam api import - maybe SteamAPI_Shutdown is better? && 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)
{
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."); 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<FARPROC>(function); return self.get_proc<FARPROC>(function);
} }
else if (function == "ExitProcess") else if (function == "ExitProcess")