From 73a05f1d91730cedda01dfb45f36f1d6d9f45d3c Mon Sep 17 00:00:00 2001 From: acidicoala <67734819+acidicoala@users.noreply.github.com> Date: Wed, 1 Feb 2023 01:26:05 +0300 Subject: [PATCH] Fixed critical bugs --- CMakeLists.txt | 2 +- src/game_mode/exports/steam_api_flat.cpp | 129 +++++++++++------- src/game_mode/virtuals/isteamapps.cpp | 93 ++++++++----- src/game_mode/virtuals/isteamclient.cpp | 69 ++++++---- src/game_mode/virtuals/isteamuser.cpp | 23 ++-- src/steam_impl/steam_apps.cpp | 22 +-- src/steam_impl/steam_apps.hpp | 4 +- .../steamclient/client_app_manager.cpp | 17 ++- src/store_mode/steamclient/client_apps.cpp | 58 ++++---- src/store_mode/steamclient/client_user.cpp | 17 ++- 10 files changed, 258 insertions(+), 176 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cc786d8..8fbc57f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.24) -project(SmokeAPI VERSION 2.0.0) +project(SmokeAPI VERSION 2.0.2) include(KoalaBox/cmake/KoalaBox.cmake) diff --git a/src/game_mode/exports/steam_api_flat.cpp b/src/game_mode/exports/steam_api_flat.cpp index 7a632e1..6956107 100644 --- a/src/game_mode/exports/steam_api_flat.cpp +++ b/src/game_mode/exports/steam_api_flat.cpp @@ -8,33 +8,51 @@ // ISteamApps DLL_EXPORT(bool) SteamAPI_ISteamApps_BIsSubscribedApp(void* self, AppId_t dlcID) { - return steam_apps::IsDlcUnlocked( - __func__, 0, dlcID, [&]() { - GET_ORIGINAL_FUNCTION_STEAMAPI(SteamAPI_ISteamApps_BIsSubscribedApp) - - return SteamAPI_ISteamApps_BIsSubscribedApp_o(self, dlcID); - } - ); + try { + static const auto app_id = steam_impl::get_app_id_or_throw(); + return steam_apps::IsDlcUnlocked( + __func__, app_id, dlcID, [&]() { + GET_ORIGINAL_FUNCTION_STEAMAPI(SteamAPI_ISteamApps_BIsSubscribedApp) + + return SteamAPI_ISteamApps_BIsSubscribedApp_o(self, dlcID); + } + ); + } catch (const Exception& e) { + LOG_ERROR("{} -> Error: {}", __func__, e.what()) + return false; + } } DLL_EXPORT(bool) SteamAPI_ISteamApps_BIsDlcInstalled(void* self, AppId_t dlcID) { - return steam_apps::IsDlcUnlocked( - __func__, 0, dlcID, [&]() { - GET_ORIGINAL_FUNCTION_STEAMAPI(SteamAPI_ISteamApps_BIsDlcInstalled) - - return SteamAPI_ISteamApps_BIsDlcInstalled_o(self, dlcID); - } - ); + try { + static const auto app_id = steam_impl::get_app_id_or_throw(); + return steam_apps::IsDlcUnlocked( + __func__, app_id, dlcID, [&]() { + GET_ORIGINAL_FUNCTION_STEAMAPI(SteamAPI_ISteamApps_BIsDlcInstalled) + + return SteamAPI_ISteamApps_BIsDlcInstalled_o(self, dlcID); + } + ); + } catch (const Exception& e) { + LOG_ERROR("{} -> Error: {}", __func__, e.what()) + return false; + } } DLL_EXPORT(int) SteamAPI_ISteamApps_GetDLCCount(void* self) { - return steam_apps::GetDLCCount( - __func__, 0, [&]() { - GET_ORIGINAL_FUNCTION_STEAMAPI(SteamAPI_ISteamApps_GetDLCCount) - - return SteamAPI_ISteamApps_GetDLCCount_o(self); - } - ); + try { + static const auto app_id = steam_impl::get_app_id_or_throw(); + return steam_apps::GetDLCCount( + __func__, app_id, [&]() { + GET_ORIGINAL_FUNCTION_STEAMAPI(SteamAPI_ISteamApps_GetDLCCount) + + return SteamAPI_ISteamApps_GetDLCCount_o(self); + } + ); + } catch (const Exception& e) { + LOG_ERROR("{} -> Error: {}", __func__, e.what()) + return 0; + } } DLL_EXPORT(bool) SteamAPI_ISteamApps_BGetDLCDataByIndex( @@ -45,19 +63,24 @@ DLL_EXPORT(bool) SteamAPI_ISteamApps_BGetDLCDataByIndex( char* pchName, int cchNameBufferSize ) { - return steam_apps::GetDLCDataByIndex( - __func__, 0, iDLC, pDlcID, pbAvailable, pchName, cchNameBufferSize, - [&]() { - GET_ORIGINAL_FUNCTION_STEAMAPI(SteamAPI_ISteamApps_BGetDLCDataByIndex) - - return SteamAPI_ISteamApps_BGetDLCDataByIndex_o( - self, iDLC, pDlcID, pbAvailable, pchName, cchNameBufferSize - ); - }, - [&](AppId_t dlc_id) { - return SteamAPI_ISteamApps_BIsDlcInstalled(self, dlc_id); - } - ); + try { + static const auto app_id = steam_impl::get_app_id_or_throw(); + return steam_apps::GetDLCDataByIndex( + __func__, app_id, iDLC, pDlcID, pbAvailable, pchName, cchNameBufferSize, + [&]() { + GET_ORIGINAL_FUNCTION_STEAMAPI(SteamAPI_ISteamApps_BGetDLCDataByIndex) + return SteamAPI_ISteamApps_BGetDLCDataByIndex_o( + self, iDLC, pDlcID, pbAvailable, pchName, cchNameBufferSize + ); + }, + [&](AppId_t dlc_id) { + return SteamAPI_ISteamApps_BIsDlcInstalled(self, dlc_id); + } + ); + } catch (const Exception& e) { + LOG_ERROR("{} -> Error: {}", __func__, e.what()) + return false; + } } // ISteamClient @@ -68,13 +91,17 @@ DLL_EXPORT(void*) SteamAPI_ISteamClient_GetISteamGenericInterface( HSteamPipe hSteamPipe, const char* pchVersion ) { - return steam_client::GetGenericInterface( - __func__, pchVersion, [&]() { - GET_ORIGINAL_FUNCTION_STEAMAPI(SteamAPI_ISteamClient_GetISteamGenericInterface) - - return SteamAPI_ISteamClient_GetISteamGenericInterface_o(self, hSteamUser, hSteamPipe, pchVersion); - } - ); + try { + return steam_client::GetGenericInterface( + __func__, pchVersion, [&]() { + GET_ORIGINAL_FUNCTION_STEAMAPI(SteamAPI_ISteamClient_GetISteamGenericInterface) + return SteamAPI_ISteamClient_GetISteamGenericInterface_o(self, hSteamUser, hSteamPipe, pchVersion); + } + ); + } catch (const Exception& e) { + LOG_ERROR("{} -> Error: {}", __func__, e.what()) + return nullptr; + } } // ISteamInventory @@ -210,18 +237,18 @@ DLL_EXPORT(EUserHasLicenseForAppResult) SteamAPI_ISteamUser_UserHasLicenseForApp CSteamID steamID, AppId_t dlcID ) { - AppId_t app_id; try { - app_id = steam_impl::get_app_id_or_throw(); + static const auto app_id = steam_impl::get_app_id_or_throw(); + return steam_user::UserHasLicenseForApp( + __func__, app_id, dlcID, [&]() { + GET_ORIGINAL_FUNCTION_STEAMAPI(SteamAPI_ISteamUser_UserHasLicenseForApp) + + return SteamAPI_ISteamUser_UserHasLicenseForApp_o(self, steamID, dlcID); + } + ); } catch (const Exception& e) { - LOG_ERROR("{} -> Error getting app id: {}", __func__, e.what()) + LOG_ERROR("{} -> Error: {}", __func__, e.what()) + return k_EUserHasLicenseResultDoesNotHaveLicense; } - return steam_user::UserHasLicenseForApp( - __func__, app_id, dlcID, [&]() { - GET_ORIGINAL_FUNCTION_STEAMAPI(SteamAPI_ISteamUser_UserHasLicenseForApp) - - return SteamAPI_ISteamUser_UserHasLicenseForApp_o(self, steamID, dlcID); - } - ); } diff --git a/src/game_mode/virtuals/isteamapps.cpp b/src/game_mode/virtuals/isteamapps.cpp index 36a128d..7e2440a 100644 --- a/src/game_mode/virtuals/isteamapps.cpp +++ b/src/game_mode/virtuals/isteamapps.cpp @@ -1,56 +1,81 @@ #include +#include #include +#include -VIRTUAL(bool) ISteamApps_BIsSubscribedApp(PARAMS(AppId_t appID)) { - return steam_apps::IsDlcUnlocked( - __func__, 0, appID, [&]() { - GET_ORIGINAL_FUNCTION_STEAMAPI(ISteamApps_BIsSubscribedApp) +VIRTUAL(bool) ISteamApps_BIsSubscribedApp(PARAMS(AppId_t dlc_id)) { + try { + static const auto app_id = steam_impl::get_app_id_or_throw(); + return steam_apps::IsDlcUnlocked( + __func__, app_id, dlc_id, [&]() { + GET_ORIGINAL_HOOKED_FUNCTION(ISteamApps_BIsSubscribedApp) + return ISteamApps_BIsSubscribedApp_o(ARGS(dlc_id)); + } + ); + } catch (const Exception& e) { + LOG_ERROR("{} -> Error: {}", __func__, e.what()) - return ISteamApps_BIsSubscribedApp_o(ARGS(appID)); - } - ); + return false; + } } -VIRTUAL(bool) ISteamApps_BIsDlcInstalled(PARAMS(AppId_t appID)) { - return steam_apps::IsDlcUnlocked( - __func__, 0, appID, [&]() { - GET_ORIGINAL_FUNCTION_STEAMAPI(ISteamApps_BIsDlcInstalled) +VIRTUAL(bool) ISteamApps_BIsDlcInstalled(PARAMS(AppId_t dlc_id)) { + try { + static const auto app_id = steam_impl::get_app_id_or_throw(); + return steam_apps::IsDlcUnlocked( + __func__, app_id, dlc_id, [&]() { + GET_ORIGINAL_HOOKED_FUNCTION(ISteamApps_BIsDlcInstalled) + return ISteamApps_BIsDlcInstalled_o(ARGS(dlc_id)); + } + ); + } catch (const Exception& e) { + LOG_ERROR("{} -> Error: {}", __func__, e.what()) - return ISteamApps_BIsDlcInstalled_o(ARGS(appID)); - } - ); + return false; + } } VIRTUAL(int) ISteamApps_GetDLCCount(PARAMS()) { - GET_ORIGINAL_HOOKED_FUNCTION(ISteamApps_GetDLCCount) + try { + static const auto app_id = steam_impl::get_app_id_or_throw(); + return steam_apps::GetDLCCount( + __func__, app_id, [&]() { + GET_ORIGINAL_HOOKED_FUNCTION(ISteamApps_GetDLCCount) + return ISteamApps_GetDLCCount_o(ARGS()); + } + ); + } catch (const Exception& e) { + LOG_ERROR("{} -> Error: {}", __func__, e.what()) - return steam_apps::GetDLCCount( - __func__, 0, [&]() { - return ISteamApps_GetDLCCount_o(ARGS()); - } - ); + return 0; + } } VIRTUAL(bool) ISteamApps_BGetDLCDataByIndex( PARAMS( int iDLC, - AppId_t* pAppID, + AppId_t* p_dlc_id, bool* pbAvailable, char* pchName, int cchNameBufferSize ) ) { - return steam_apps::GetDLCDataByIndex( - __func__, 0, iDLC, pAppID, pbAvailable, pchName, cchNameBufferSize, - [&]() { - GET_ORIGINAL_HOOKED_FUNCTION(ISteamApps_BGetDLCDataByIndex) - - return ISteamApps_BGetDLCDataByIndex_o( - ARGS(iDLC, pAppID, pbAvailable, pchName, cchNameBufferSize) - ); - }, - [&](AppId_t dlc_id) { - return ISteamApps_BIsDlcInstalled(ARGS(dlc_id)); - } - ); + try { + static const auto app_id = steam_impl::get_app_id_or_throw(); + return steam_apps::GetDLCDataByIndex( + __func__, app_id, iDLC, p_dlc_id, pbAvailable, pchName, cchNameBufferSize, + [&]() { + GET_ORIGINAL_HOOKED_FUNCTION(ISteamApps_BGetDLCDataByIndex) + return ISteamApps_BGetDLCDataByIndex_o( + ARGS(iDLC, p_dlc_id, pbAvailable, pchName, cchNameBufferSize) + ); + }, + [&](AppId_t dlc_id) { + return ISteamApps_BIsDlcInstalled(ARGS(dlc_id)); + } + ); + } catch (const Exception& e) { + LOG_ERROR("{} -> Error: {}", __func__, e.what()) + return false; + } } diff --git a/src/game_mode/virtuals/isteamclient.cpp b/src/game_mode/virtuals/isteamclient.cpp index 47906ba..2a3e466 100644 --- a/src/game_mode/virtuals/isteamclient.cpp +++ b/src/game_mode/virtuals/isteamclient.cpp @@ -8,13 +8,17 @@ VIRTUAL(void*) ISteamClient_GetISteamApps( const char* version ) ) { - return steam_client::GetGenericInterface( - __func__, version, [&]() { - GET_ORIGINAL_HOOKED_FUNCTION(ISteamClient_GetISteamApps) - - return ISteamClient_GetISteamApps_o(ARGS(hSteamUser, hSteamPipe, version)); - } - ); + try { + return steam_client::GetGenericInterface( + __func__, version, [&]() { + GET_ORIGINAL_HOOKED_FUNCTION(ISteamClient_GetISteamApps) + return ISteamClient_GetISteamApps_o(ARGS(hSteamUser, hSteamPipe, version)); + } + ); + } catch (const Exception& e) { + LOG_ERROR("{} -> Error: {}", __func__, e.what()) + return nullptr; + } } VIRTUAL(void*) ISteamClient_GetISteamUser( @@ -24,13 +28,18 @@ VIRTUAL(void*) ISteamClient_GetISteamUser( const char* version ) ) { - return steam_client::GetGenericInterface( - __func__, version, [&]() { - GET_ORIGINAL_HOOKED_FUNCTION(ISteamClient_GetISteamUser) + try { + return steam_client::GetGenericInterface( + __func__, version, [&]() { + GET_ORIGINAL_HOOKED_FUNCTION(ISteamClient_GetISteamUser) - return ISteamClient_GetISteamUser_o(ARGS(hSteamUser, hSteamPipe, version)); - } - ); + return ISteamClient_GetISteamUser_o(ARGS(hSteamUser, hSteamPipe, version)); + } + ); + } catch (const Exception& e) { + LOG_ERROR("{} -> Error: {}", __func__, e.what()) + return nullptr; + } } VIRTUAL(void*) ISteamClient_GetISteamGenericInterface( @@ -40,13 +49,18 @@ VIRTUAL(void*) ISteamClient_GetISteamGenericInterface( const char* pchVersion ) ) { - return steam_client::GetGenericInterface( - __func__, pchVersion, [&]() { - GET_ORIGINAL_HOOKED_FUNCTION(ISteamClient_GetISteamGenericInterface) + try { + return steam_client::GetGenericInterface( + __func__, pchVersion, [&]() { + GET_ORIGINAL_HOOKED_FUNCTION(ISteamClient_GetISteamGenericInterface) - return ISteamClient_GetISteamGenericInterface_o(ARGS(hSteamUser, hSteamPipe, pchVersion)); - } - ); + return ISteamClient_GetISteamGenericInterface_o(ARGS(hSteamUser, hSteamPipe, pchVersion)); + } + ); + } catch (const Exception& e) { + LOG_ERROR("{} -> Error: {}", __func__, e.what()) + return nullptr; + } } VIRTUAL(void*) ISteamClient_GetISteamInventory( @@ -56,11 +70,16 @@ VIRTUAL(void*) ISteamClient_GetISteamInventory( const char* pchVersion ) ) { - return steam_client::GetGenericInterface( - __func__, pchVersion, [&]() { - GET_ORIGINAL_HOOKED_FUNCTION(ISteamClient_GetISteamInventory) + try { + return steam_client::GetGenericInterface( + __func__, pchVersion, [&]() { + GET_ORIGINAL_HOOKED_FUNCTION(ISteamClient_GetISteamInventory) - return ISteamClient_GetISteamInventory_o(ARGS(hSteamUser, hSteamPipe, pchVersion)); - } - ); + return ISteamClient_GetISteamInventory_o(ARGS(hSteamUser, hSteamPipe, pchVersion)); + } + ); + } catch (const Exception& e) { + LOG_ERROR("{} -> Error: {}", __func__, e.what()) + return nullptr; + } } diff --git a/src/game_mode/virtuals/isteamuser.cpp b/src/game_mode/virtuals/isteamuser.cpp index a23e1e3..6e0cd5f 100644 --- a/src/game_mode/virtuals/isteamuser.cpp +++ b/src/game_mode/virtuals/isteamuser.cpp @@ -3,19 +3,18 @@ #include #include -VIRTUAL(EUserHasLicenseForAppResult) ISteamUser_UserHasLicenseForApp(PARAMS(CSteamID steamID, AppId_t dlcID)) { - AppId_t app_id = 0; +VIRTUAL(EUserHasLicenseForAppResult) ISteamUser_UserHasLicenseForApp(PARAMS(CSteamID steamID, AppId_t dlc_id)) { try { - app_id = steam_impl::get_app_id_or_throw(); + static const auto app_id = steam_impl::get_app_id_or_throw(); + return steam_user::UserHasLicenseForApp( + __func__, app_id, dlc_id, [&]() { + GET_ORIGINAL_HOOKED_FUNCTION(ISteamUser_UserHasLicenseForApp) + + return ISteamUser_UserHasLicenseForApp_o(ARGS(steamID, dlc_id)); + } + ); } catch (const Exception& e) { - LOG_ERROR("{} -> Error getting app id: {}", __func__, e.what()) + LOG_ERROR("{} -> Error: {}", __func__, e.what()) + return k_EUserHasLicenseResultDoesNotHaveLicense; } - - return steam_user::UserHasLicenseForApp( - __func__, app_id, dlcID, [&]() { - GET_ORIGINAL_HOOKED_FUNCTION(ISteamUser_UserHasLicenseForApp) - - return ISteamUser_UserHasLicenseForApp_o(ARGS(steamID, dlcID)); - } - ); } diff --git a/src/steam_impl/steam_apps.cpp b/src/steam_impl/steam_apps.cpp index 2c021a4..0395b73 100644 --- a/src/steam_impl/steam_apps.cpp +++ b/src/steam_impl/steam_apps.cpp @@ -25,20 +25,13 @@ namespace steam_apps { * @return boolean indicating if the function was able to successfully fetch DLC IDs from all sources. */ void fetch_and_cache_dlcs(AppId_t app_id) { - static std::mutex mutex; - const std::lock_guard guard(mutex); - - if (not app_id) { - // No app id means we are operating in game mode. - // Hence, we need to use utility functions to get app id. - try { - app_id = steam_impl::get_app_id_or_throw(); - LOG_INFO("Detected App ID: {}", app_id) - } catch (const Exception& ex) { - LOG_ERROR("Failed to get app ID: {}", ex.what()) - app_dlcs[app_id] = {}; // Dummy value to avoid checking for presence on each access - return; - } + static Mutex mutex; + const MutexLockGuard guard(mutex); + + if (app_id == 0) { + LOG_ERROR("{} -> App ID is 0", __func__) + app_dlcs[app_id] = {}; // Dummy value to avoid checking for presence on each access + return; } // We want to fetch data only once. However, if any of the remote sources have failed @@ -75,7 +68,6 @@ namespace steam_apps { } // Cache DLCs in memory and cache for future use - app_dlcs[app_id] = aggregated_dlcs; smoke_api::app_cache::save_dlcs(app_id, aggregated_dlcs); diff --git a/src/steam_impl/steam_apps.hpp b/src/steam_impl/steam_apps.hpp index ae9bb3d..8203afa 100644 --- a/src/steam_impl/steam_apps.hpp +++ b/src/steam_impl/steam_apps.hpp @@ -18,8 +18,8 @@ namespace steam_apps { ); bool GetDLCDataByIndex( - const String& dlc_id, - AppId_t dlc_ids, + const String& function_name, + AppId_t app_id, int iDLC, AppId_t* pDlcId, bool* pbAvailable, diff --git a/src/store_mode/steamclient/client_app_manager.cpp b/src/store_mode/steamclient/client_app_manager.cpp index 7d3fabc..399ea02 100644 --- a/src/store_mode/steamclient/client_app_manager.cpp +++ b/src/store_mode/steamclient/client_app_manager.cpp @@ -2,11 +2,16 @@ #include VIRTUAL(bool) IClientAppManager_IsAppDlcInstalled(PARAMS(AppId_t app_id, AppId_t dlc_id)) { - return steam_apps::IsDlcUnlocked( - __func__, app_id, dlc_id, [&]() { - GET_ORIGINAL_HOOKED_FUNCTION(IClientAppManager_IsAppDlcInstalled) + try { + return steam_apps::IsDlcUnlocked( + __func__, app_id, dlc_id, [&]() { + GET_ORIGINAL_HOOKED_FUNCTION(IClientAppManager_IsAppDlcInstalled) - return IClientAppManager_IsAppDlcInstalled_o(ARGS(app_id, dlc_id)); - } - ); + return IClientAppManager_IsAppDlcInstalled_o(ARGS(app_id, dlc_id)); + } + ); + } catch (const Exception& e) { + LOG_ERROR("{} -> Error: {}", __func__, e.what()) + return false; + } } diff --git a/src/store_mode/steamclient/client_apps.cpp b/src/store_mode/steamclient/client_apps.cpp index 8ab1def..0b9a172 100644 --- a/src/store_mode/steamclient/client_apps.cpp +++ b/src/store_mode/steamclient/client_apps.cpp @@ -2,13 +2,18 @@ #include VIRTUAL(int) IClientApps_GetDLCCount(PARAMS(AppId_t appId)) { - return steam_apps::GetDLCCount( - __func__, appId, [&]() { - GET_ORIGINAL_HOOKED_FUNCTION(IClientApps_GetDLCCount) + try { + return steam_apps::GetDLCCount( + __func__, appId, [&]() { + GET_ORIGINAL_HOOKED_FUNCTION(IClientApps_GetDLCCount) - return IClientApps_GetDLCCount_o(ARGS(appId)); - } - ); + return IClientApps_GetDLCCount_o(ARGS(appId)); + } + ); + } catch (const Exception& e) { + LOG_ERROR("{} -> Error: {}", __func__, e.what()) + return 0; + } } VIRTUAL(bool) IClientApps_BGetDLCDataByIndex( @@ -21,24 +26,29 @@ VIRTUAL(bool) IClientApps_BGetDLCDataByIndex( int cchNameBufferSize ) ) { - return steam_apps::GetDLCDataByIndex( - __func__, appID, iDLC, pDlcID, pbAvailable, pchName, cchNameBufferSize, - [&]() { - GET_ORIGINAL_HOOKED_FUNCTION(IClientApps_BGetDLCDataByIndex) + try { + return steam_apps::GetDLCDataByIndex( + __func__, appID, iDLC, pDlcID, pbAvailable, pchName, cchNameBufferSize, + [&]() { + GET_ORIGINAL_HOOKED_FUNCTION(IClientApps_BGetDLCDataByIndex) - return IClientApps_BGetDLCDataByIndex_o( - ARGS(appID, iDLC, pDlcID, pbAvailable, pchName, cchNameBufferSize) - ); - }, - [&](AppId_t dlc_id) { - const auto* app_manager_interface = store::steamclient::interface_name_to_address_map["IClientAppManager"]; - if (app_manager_interface) { - IClientAppManager_IsAppDlcInstalled(app_manager_interface, EDX, appID, dlc_id); - return true; - } + return IClientApps_BGetDLCDataByIndex_o( + ARGS(appID, iDLC, pDlcID, pbAvailable, pchName, cchNameBufferSize) + ); + }, + [&](AppId_t dlc_id) { + const auto* app_manager_interface = store::steamclient::interface_name_to_address_map["IClientAppManager"]; + if (app_manager_interface) { + IClientAppManager_IsAppDlcInstalled(app_manager_interface, EDX, appID, dlc_id); + return true; + } - // Would never happen in practice, as the interfaces would be instantiated almost simultaneously - return false; - } - ); + // Would never happen in practice, as the interfaces would be instantiated almost simultaneously + return false; + } + ); + } catch (const Exception& e) { + LOG_ERROR("{} -> Error: {}", __func__, e.what()) + return false; + } } diff --git a/src/store_mode/steamclient/client_user.cpp b/src/store_mode/steamclient/client_user.cpp index 0a48d1d..52c4ef6 100644 --- a/src/store_mode/steamclient/client_user.cpp +++ b/src/store_mode/steamclient/client_user.cpp @@ -2,13 +2,18 @@ #include VIRTUAL(bool) IClientUser_BIsSubscribedApp(PARAMS(AppId_t dlc_id)) { - const auto* utils_interface = store::steamclient::interface_name_to_address_map["IClientUtils"]; + try { + const auto* utils_interface = store::steamclient::interface_name_to_address_map["IClientUtils"]; - const auto app_id = utils_interface ? IClientUtils_GetAppID(utils_interface, EDX) : 0; + const auto app_id = utils_interface ? IClientUtils_GetAppID(utils_interface, EDX) : 0; - return steam_apps::IsDlcUnlocked(__func__, app_id, dlc_id, [&]() { - GET_ORIGINAL_HOOKED_FUNCTION(IClientUser_BIsSubscribedApp) + return steam_apps::IsDlcUnlocked(__func__, app_id, dlc_id, [&]() { + GET_ORIGINAL_HOOKED_FUNCTION(IClientUser_BIsSubscribedApp) - return IClientUser_BIsSubscribedApp_o(ARGS(dlc_id)); - }); + return IClientUser_BIsSubscribedApp_o(ARGS(dlc_id)); + }); + } catch (const Exception& e) { + LOG_ERROR("{} -> Error: {}", __func__, e.what()) + return false; + } }