steam_proxy: use wide strings

This commit is contained in:
FutureRave 2023-03-03 10:59:39 +00:00
parent acd999a425
commit 2bccc53eea
No known key found for this signature in database
GPG Key ID: 22F9079C86CFAB31
4 changed files with 117 additions and 117 deletions

View File

@ -34,7 +34,7 @@ public:
this->start_mod("\xF0\x9F\x90\x8D Open-IW5 Multiplayer", 42690);
}
}
catch (std::exception& e)
catch (const std::exception& e)
{
printf("Steam: %s\n", e.what());
}

View File

@ -75,22 +75,22 @@ namespace steam
results_.clear();
}
std::string get_steam_install_directory()
std::wstring get_steam_install_directory()
{
HKEY reg_key;
if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, "Software\\Valve\\Steam", 0, KEY_QUERY_VALUE, &reg_key) ==
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"Software\\Valve\\Steam", 0, KEY_QUERY_VALUE, &reg_key) ==
ERROR_SUCCESS)
{
char path[MAX_PATH] = {0};
wchar_t path[MAX_PATH]{};
DWORD length = sizeof(path);
RegQueryValueExA(reg_key, "InstallPath", nullptr, nullptr, reinterpret_cast<BYTE*>(path),
RegQueryValueExW(reg_key, L"InstallPath", nullptr, nullptr, reinterpret_cast<BYTE*>(path),
&length);
RegCloseKey(reg_key);
std::string steam_path = path;
if (steam_path.back() != '\\' && steam_path.back() != '/')
std::wstring steam_path = path;
if (steam_path.back() != L'\\' && steam_path.back() != L'/')
{
steam_path.push_back('\\');
steam_path.push_back(L'\\');
}
return steam_path;
@ -99,7 +99,8 @@ namespace steam
return {};
}
extern "C" {
extern "C"
{
bool SteamAPI_RestartAppIfNecessary()
{
return false;
@ -111,10 +112,10 @@ namespace steam
if (!overlay)
{
const auto steam_path = get_steam_install_directory();
const std::filesystem::path steam_path = ::steam::get_steam_install_directory();
if (!steam_path.empty())
{
overlay = ::utils::nt::library::load(steam_path + "gameoverlayrenderer.dll");
overlay = ::utils::nt::library::load(steam_path / "gameoverlayrenderer.dll");
}
}
@ -148,7 +149,6 @@ namespace steam
{
}
bool SteamGameServer_Init()
{
return true;

View File

@ -118,7 +118,7 @@ namespace steam
STEAM_EXPORT apps* SteamApps();
STEAM_EXPORT user_stats* SteamUserStats();
std::string get_steam_install_directory();
std::wstring get_steam_install_directory();
extern ::utils::nt::library overlay;
}

View File

@ -10,7 +10,7 @@ namespace utils::nt
library library::load(const std::filesystem::path& path)
{
return library::load(path.generic_string());
return library(LoadLibraryW(path.generic_wstring().data()));
}
library library::get_by_address(void* address)