mirror of
https://github.com/acidicoala/SmokeAPI.git
synced 2026-05-04 19:42:15 -04:00
Renamed koalageddon mode to store mode
This commit is contained in:
@@ -1,52 +0,0 @@
|
||||
#include <smoke_api/app_cache.hpp>
|
||||
#include <core/paths.hpp>
|
||||
#include <koalabox/cache.hpp>
|
||||
#include <koalabox/logger.hpp>
|
||||
|
||||
constexpr auto KEY_APPS = "apps";
|
||||
|
||||
AppDlcNameMap get_cached_apps() noexcept {
|
||||
try {
|
||||
const auto cache = koalabox::cache::read_from_cache(KEY_APPS);
|
||||
|
||||
return cache.get<AppDlcNameMap>();
|
||||
} catch (const Exception& e) {
|
||||
LOG_WARN("Failed to get cached apps: {}", e.what())
|
||||
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
namespace smoke_api::app_cache {
|
||||
|
||||
Vector<DLC> get_dlcs(AppId_t app_id) noexcept {
|
||||
try {
|
||||
LOG_DEBUG("Reading cached DLC IDs for the app: {}", app_id)
|
||||
|
||||
const auto apps = get_cached_apps();
|
||||
|
||||
return DLC::get_dlcs_from_apps(apps, app_id);
|
||||
} catch (const Exception& e) {
|
||||
LOG_ERROR("Error reading DLCs from disk cache: ", e.what())
|
||||
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
bool save_dlcs(AppId_t app_id, const Vector<DLC>& dlcs) noexcept {
|
||||
try {
|
||||
LOG_DEBUG("Caching DLC IDs for the app: {}", app_id)
|
||||
|
||||
auto apps = get_cached_apps();
|
||||
|
||||
apps[std::to_string(app_id)] = App{.dlcs=DLC::get_dlc_map_from_vector(dlcs)};
|
||||
|
||||
return koalabox::cache::save_to_cache(KEY_APPS, Json(apps));
|
||||
} catch (const Exception& e) {
|
||||
LOG_ERROR("Error saving DLCs to disk cache: {}", e.what())
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <core/types.hpp>
|
||||
|
||||
namespace smoke_api::app_cache {
|
||||
|
||||
Vector<DLC> get_dlcs(AppId_t app_id) noexcept;
|
||||
|
||||
bool save_dlcs(AppId_t app_id, const Vector<DLC>& dlcs) noexcept;
|
||||
|
||||
}
|
||||
@@ -7,7 +7,7 @@
|
||||
namespace smoke_api::config {
|
||||
Config instance; // NOLINT(cert-err58-cpp)
|
||||
|
||||
void init() {
|
||||
void init_config() {
|
||||
const auto path = paths::get_config_path();
|
||||
|
||||
if (exists(path)) {
|
||||
@@ -66,6 +66,6 @@ namespace smoke_api::config {
|
||||
DLL_EXPORT(void) ReloadConfig() {
|
||||
LOG_INFO("Reloading config")
|
||||
|
||||
init();
|
||||
init_config();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <core/types.hpp>
|
||||
#include <koalabox/core.hpp>
|
||||
|
||||
namespace smoke_api::config {
|
||||
|
||||
@@ -30,7 +29,7 @@ namespace smoke_api::config {
|
||||
bool auto_inject_inventory = true;
|
||||
Vector<uint32_t> extra_inventory_items;
|
||||
// We have to use general json type here since the library doesn't support std::optional
|
||||
Json koalageddon_config;
|
||||
Json store_config;
|
||||
|
||||
NLOHMANN_DEFINE_TYPE_INTRUSIVE(
|
||||
Config, // NOLINT(misc-const-correctness)
|
||||
@@ -43,13 +42,13 @@ namespace smoke_api::config {
|
||||
extra_dlcs,
|
||||
auto_inject_inventory,
|
||||
extra_inventory_items,
|
||||
koalageddon_config
|
||||
store_config
|
||||
)
|
||||
};
|
||||
|
||||
extern Config instance;
|
||||
|
||||
void init();
|
||||
void init_config();
|
||||
|
||||
Vector<DLC> get_extra_dlcs(AppId_t app_id);
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <smoke_api/config.hpp>
|
||||
#include <core/globals.hpp>
|
||||
#include <core/paths.hpp>
|
||||
#include <common/steamclient_exports.hpp>
|
||||
#include <koalabox/dll_monitor.hpp>
|
||||
#include <koalabox/logger.hpp>
|
||||
#include <koalabox/hook.hpp>
|
||||
@@ -10,12 +11,30 @@
|
||||
#include <koalabox/loader.hpp>
|
||||
#include <koalabox/win_util.hpp>
|
||||
#include <koalabox/util.hpp>
|
||||
#include <steam_api_exports/steam_api_exports.hpp>
|
||||
//#include <steam_api_exports/steam_api_exports.hpp>
|
||||
|
||||
#if COMPILE_KOALAGEDDON
|
||||
#include <koalageddon/koalageddon.hpp>
|
||||
#if COMPILE_STORE_MODE
|
||||
#include <store_mode/store.hpp>
|
||||
#endif
|
||||
|
||||
// Hooking steam_api has shown itself to be less desirable than steamclient
|
||||
// for the reasons outlined below:
|
||||
//
|
||||
// Calling original in flat functions will actually call the hooked functions
|
||||
// because the original function redirects the execution to a function taken
|
||||
// from self pointer, which would have been hooked by SteamInternal_*Interface
|
||||
// functions.
|
||||
//
|
||||
// Furthermore, turns out that many flat functions share the same body,
|
||||
// which looks like the following snippet:
|
||||
//
|
||||
// mov rax, qword ptr ds:[rcx]
|
||||
// jmp qword ptr ds:[rax+immediate]
|
||||
//
|
||||
// This means that we end up inadvertently hooking unintended functions.
|
||||
// Given that hooking steam_api has no apparent benefits, but has inherent flaws,
|
||||
// the support for it has been dropped from this project.
|
||||
|
||||
void init_proxy_mode() {
|
||||
LOG_INFO("🔀 Detected proxy mode")
|
||||
|
||||
@@ -34,24 +53,6 @@ void init_hook_mode() {
|
||||
koalabox::dll_monitor::shutdown_listener();
|
||||
}
|
||||
);
|
||||
|
||||
// Hooking steam_api has shown itself to be less desirable than steamclient
|
||||
// for the reasons outlined below:
|
||||
//
|
||||
// Calling original in flat functions will actually call the hooked functions
|
||||
// because the original function redirects the execution to a function taken
|
||||
// from self pointer, which would have been hooked by SteamInternal_*Interface
|
||||
// functions.
|
||||
//
|
||||
// Furthermore, turns out that many flat functions share the same body,
|
||||
// which looks like the following snippet:
|
||||
//
|
||||
// mov rax, qword ptr ds:[rcx]
|
||||
// jmp qword ptr ds:[rax+immediate]
|
||||
//
|
||||
// This means that we end up inadvertently hooking unintended functions.
|
||||
// Given that hooking steam_api has no apparent benefits, but has inherent flaws,
|
||||
// the support for it has been dropped from this project.
|
||||
}
|
||||
|
||||
bool is_valve_steam(const String& exe_name) noexcept {
|
||||
@@ -82,7 +83,7 @@ namespace smoke_api {
|
||||
|
||||
globals::smokeapi_handle = module_handle;
|
||||
|
||||
config::init();
|
||||
config::init_config();
|
||||
|
||||
if (config::instance.logging) {
|
||||
koalabox::logger::init_file_logger(paths::get_log_path());
|
||||
@@ -103,9 +104,9 @@ namespace smoke_api {
|
||||
koalabox::hook::init(true);
|
||||
|
||||
if (is_valve_steam(exe_name)) {
|
||||
#if COMPILE_KOALAGEDDON
|
||||
LOG_INFO("🐨💥 Detected Koalageddon mode")
|
||||
koalageddon::init();
|
||||
#if COMPILE_STORE_MODE
|
||||
LOG_INFO("🛍️ Detected Store mode")
|
||||
store::init_store_mode();
|
||||
#endif
|
||||
} else {
|
||||
init_hook_mode();
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace smoke_api {
|
||||
|
||||
void init(HMODULE module_handle);
|
||||
|
||||
void shutdown();
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user