From cbda647d43d957fdd4291be3bdebc05c2a2dbb6d Mon Sep 17 00:00:00 2001 From: acidicoala Date: Sat, 17 Apr 2021 20:16:08 +0300 Subject: [PATCH] Added app_blacklist option for Steam --- Common/src/Config.cpp | 1 + Common/src/Config.h | 1 + Common/src/constants.h | 2 +- Config.jsonc | 5 +- IntegrationWizard/src/winmain.cpp | 2 +- .../steam_client/steam_client_hooks.cpp | 55 ++++++++++++++++--- inno_setup.iss | 2 +- 7 files changed, 55 insertions(+), 13 deletions(-) diff --git a/Common/src/Config.cpp b/Common/src/Config.cpp index d329239..ec27e0d 100644 --- a/Common/src/Config.cpp +++ b/Common/src/Config.cpp @@ -12,6 +12,7 @@ void from_json(const json& j, SteamPlatform& p) from_json(j, (Platform&) p); j["unlock_shared_library"].get_to(p.unlock_shared_library); j["unlock_dlc"].get_to(p.unlock_dlc); + j["app_blacklist"].get_to(p.app_blacklist); } NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Platforms, Steam, EpicGames, Origin, EADesktop, UplayR1) diff --git a/Common/src/Config.h b/Common/src/Config.h index 6e20b0a..881cb4d 100644 --- a/Common/src/Config.h +++ b/Common/src/Config.h @@ -15,6 +15,7 @@ struct SteamPlatform : Platform { bool unlock_dlc = true; bool unlock_shared_library = false; + vector app_blacklist; }; struct Platforms diff --git a/Common/src/constants.h b/Common/src/constants.h index 23429ec..b29baf5 100644 --- a/Common/src/constants.h +++ b/Common/src/constants.h @@ -1,6 +1,6 @@ #pragma once -constexpr auto VERSION = "1.5.1"; +constexpr auto VERSION = "1.5.2"; constexpr auto INTEGRATION_64 = L"Integration64.dll"; constexpr auto INTEGRATION_32 = L"Integration32.dll"; diff --git a/Config.jsonc b/Config.jsonc index 016d918..cc05659 100644 --- a/Config.jsonc +++ b/Config.jsonc @@ -1,5 +1,5 @@ { - "config_version": 5, // DO NOT EDIT THIS VALUE + "config_version": 6, // DO NOT EDIT THIS VALUE "log_level": "debug", "platforms": { "Steam": { @@ -8,6 +8,9 @@ "replicate": false, "unlock_dlc": true, "unlock_shared_library": false, + "app_blacklist": [ + "976310" // Mortal Kombat 11 + ], "blacklist": [ // Get App ID from SteamDB "22618", // Alien Breed: Impact - PL Check [Do not force polish language] "67379" // Darkness II Low Violence [Do not censor violence] diff --git a/IntegrationWizard/src/winmain.cpp b/IntegrationWizard/src/winmain.cpp index 3b0d93d..9bab888 100644 --- a/IntegrationWizard/src/winmain.cpp +++ b/IntegrationWizard/src/winmain.cpp @@ -98,7 +98,7 @@ void askForAction( LR"(🌐 Open latest release page ({0}) 📂 Open config directory ({1}))" - , L"https://github.com/acidicoala/Koalageddon/releases", getConfigPath().parent_path().wstring()); + , L"https://github.com/acidicoala/Koalageddon/releases/latest", getConfigPath().parent_path().wstring()); tdc.hInstance = hInstance; tdc.dwFlags = TDF_ALLOW_DIALOG_CANCELLATION | TDF_USE_COMMAND_LINKS | TDF_EXPAND_FOOTER_AREA | TDF_ENABLE_HYPERLINKS; diff --git a/Unlocker/src/platforms/steam_client/steam_client_hooks.cpp b/Unlocker/src/platforms/steam_client/steam_client_hooks.cpp index 164c76c..68efb6e 100644 --- a/Unlocker/src/platforms/steam_client/steam_client_hooks.cpp +++ b/Unlocker/src/platforms/steam_client/steam_client_hooks.cpp @@ -2,37 +2,74 @@ #include "Logger.h" #include "steam_client_hooks.h" +#define GET_ORIGINAL_FUNC(NAME) PLH::FnCast(BasePlatform::trampolineMap[#NAME], NAME) + +// Utility functions + auto isBlacklistedInSteam(int dlcID) { return vectorContains(config->platformRefs.Steam.blacklist, std::to_string(dlcID)); } +auto isAppBlacklisted(int appID) +{ + return vectorContains(config->platformRefs.Steam.app_blacklist, std::to_string(appID)); +} + /// DLC Unlocking hooks HOOK_SPEC(bool) IsAppDLCEnabled(PARAMS(int appID, int dlcID)) { - auto enabled = !isBlacklistedInSteam(dlcID); + bool enabled; + + if(isAppBlacklisted(appID)) + { + logger->debug("IsAppDLCEnabled -> Blacklisted AppID. Redirecting to original."); + static auto original = GET_ORIGINAL_FUNC(IsAppDLCEnabled); + enabled = original(ARGS(appID, dlcID)); + } + else + { + enabled = !isBlacklistedInSteam(dlcID); + } + logger->debug("IsAppDLCEnabled -> AppID: {}, DLC ID: {}. Enabled: {}", appID, dlcID, enabled); return enabled; } HOOK_SPEC(bool) IsSubscribedApp(PARAMS(int appID)) { - auto subscribed = !isBlacklistedInSteam(appID); + bool subscribed; + if(isAppBlacklisted(appID)) + { + logger->debug("GetDLCDataByIndex -> Blacklisted AppID. Redirecting to original."); + static auto original = GET_ORIGINAL_FUNC(IsSubscribedApp); + subscribed = original(ARGS(appID)); + } + else + { + subscribed = !isBlacklistedInSteam(appID); + } + logger->debug("IsSubscribedApp -> AppID: {}. Subscribed: {}", appID, subscribed); return subscribed; } -HOOK_SPEC(bool) GetDLCDataByIndex(PARAMS(int appID, int index, int* pDlcID , bool* pbAvailable, char* pchName, int bufferSize)) +HOOK_SPEC(bool) GetDLCDataByIndex(PARAMS(int appID, int index, int* pDlcID, bool* pbAvailable, char* pchName, int bufferSize)) { - auto result = PLH::FnCast( - BasePlatform::trampolineMap[__func__], - GetDLCDataByIndex - )(ARGS(appID, index, pDlcID, pbAvailable, pchName, bufferSize)); + static auto original = GET_ORIGINAL_FUNC(GetDLCDataByIndex); + auto result = original(ARGS(appID, index, pDlcID, pbAvailable, pchName, bufferSize)); - logger->info("GetDLCDataByIndex -> index: {}, DLC ID: {}, available: {}, name: '{}'", index, *pDlcID, *pbAvailable, pchName); + if(isAppBlacklisted(appID)) + { + logger->debug("GetDLCDataByIndex -> Blacklisted AppID. Skipping any modifications."); + } + else if(result) + { + *pbAvailable = !isBlacklistedInSteam(*pDlcID); + } - *pbAvailable = !isBlacklistedInSteam(*pDlcID); + logger->info("GetDLCDataByIndex -> index: {}, DLC ID: {}, available: {}, name: '{}'", index, *pDlcID, *pbAvailable, pchName); return result; } diff --git a/inno_setup.iss b/inno_setup.iss index ee92a70..b93fef4 100644 --- a/inno_setup.iss +++ b/inno_setup.iss @@ -2,7 +2,7 @@ ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! #define MyAppName "Koalageddon" -#define MyAppVersion "1.5.1" +#define MyAppVersion "1.5.2" #define MyAppPublisher "acidicoala" #define MyAppURL "https://github.com/acidicoala/Koalageddon" #define MyAppExeName "IntegrationWizard32.exe"