mirror of
https://github.com/acidicoala/SmokeAPI.git
synced 2026-01-24 13:32:51 -05:00
Added remote koalageddon config source
This commit is contained in:
6
.idea/encodings.xml
generated
6
.idea/encodings.xml
generated
@@ -1,6 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="Encoding">
|
|
||||||
<file url="file://$PROJECT_DIR$/include/sdk/steamtypes.h" charset="windows-1252" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
||||||
@@ -2,6 +2,8 @@
|
|||||||
#include <koalageddon/koalageddon.hpp>
|
#include <koalageddon/koalageddon.hpp>
|
||||||
#include <smoke_api/smoke_api.hpp>
|
#include <smoke_api/smoke_api.hpp>
|
||||||
#include <koalabox/dll_monitor.hpp>
|
#include <koalabox/dll_monitor.hpp>
|
||||||
|
#include <koalabox/http_client.hpp>
|
||||||
|
#include <koalabox/io.hpp>
|
||||||
|
|
||||||
namespace koalageddon {
|
namespace koalageddon {
|
||||||
KoalageddonConfig config = {};
|
KoalageddonConfig config = {};
|
||||||
@@ -10,16 +12,41 @@ namespace koalageddon {
|
|||||||
* @return A string representing the source of the config.
|
* @return A string representing the source of the config.
|
||||||
*/
|
*/
|
||||||
String init_koalageddon_config() {
|
String init_koalageddon_config() {
|
||||||
|
if (!smoke_api::config.koalageddon_config.is_null()) {
|
||||||
try {
|
try {
|
||||||
// First try to read a local config override
|
// First try to read a local config override
|
||||||
config = smoke_api::config.koalageddon_config.get<KoalageddonConfig>();
|
config = smoke_api::config.koalageddon_config.get<decltype(config)>();
|
||||||
|
|
||||||
return "local config override";
|
return "local config override";
|
||||||
} catch (const Exception& ex) {
|
} catch (const Exception& ex) {
|
||||||
logger->debug("Local koalageddon config parse exception: {}", ex.what());
|
logger->error("Local koalageddon config parse exception: {}", ex.what());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Remote source with local cache
|
const auto config_cache_path = smoke_api::self_directory / "SmokeAPI.koalageddon.json";
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Then try to fetch config from GitHub
|
||||||
|
const String url = "https://raw.githubusercontent.com/acidicoala/public-entitlements/main/koalageddon/v2/steam.json";
|
||||||
|
config = http_client::fetch_json(url).get<decltype(config)>();
|
||||||
|
|
||||||
|
io::write_file(config_cache_path, nlohmann::json(config).dump(2));
|
||||||
|
|
||||||
|
return "GitHub repository";
|
||||||
|
} catch (const Exception& ex) {
|
||||||
|
logger->error("Remote koalageddon config parse exception: {}", ex.what());
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Then try to get a cached copy of a previously fetched config
|
||||||
|
const auto cache = io::read_file(config_cache_path);
|
||||||
|
|
||||||
|
config = nlohmann::json::parse(cache).get<decltype(config)>();
|
||||||
|
|
||||||
|
return "Local cache";
|
||||||
|
} catch (const Exception& ex) {
|
||||||
|
logger->error("Cached koalageddon config parse exception: {}", ex.what());
|
||||||
|
}
|
||||||
|
|
||||||
// Finally, fallback on the default config
|
// Finally, fallback on the default config
|
||||||
return "default config bundled in the binary";
|
return "default config bundled in the binary";
|
||||||
@@ -29,21 +56,30 @@ namespace koalageddon {
|
|||||||
#ifndef _WIN64
|
#ifndef _WIN64
|
||||||
logger->info("🐨 Detected Koalageddon mode 💥");
|
logger->info("🐨 Detected Koalageddon mode 💥");
|
||||||
|
|
||||||
|
std::thread([]() {
|
||||||
const auto kg_config_source = init_koalageddon_config();
|
const auto kg_config_source = init_koalageddon_config();
|
||||||
logger->info("Loaded Koalageddon config from the {}", kg_config_source);
|
logger->info("Loaded Koalageddon config from the {}", kg_config_source);
|
||||||
|
}).detach();
|
||||||
|
|
||||||
dll_monitor::init({VSTDLIB_DLL, STEAMCLIENT_DLL}, [](const HMODULE& library, const String& name) {
|
dll_monitor::init({VSTDLIB_DLL, STEAMCLIENT_DLL}, [](const HMODULE& library, const String& name) {
|
||||||
try {
|
try {
|
||||||
smoke_api::original_library = library;
|
smoke_api::original_library = library;
|
||||||
|
|
||||||
|
static auto init_count = 0;
|
||||||
if (name == VSTDLIB_DLL) {
|
if (name == VSTDLIB_DLL) {
|
||||||
// VStdLib DLL handles Family Sharing functions
|
// VStdLib DLL handles Family Sharing functions
|
||||||
if (smoke_api::config.unlock_family_sharing) {
|
if (smoke_api::config.unlock_family_sharing) {
|
||||||
init_vstdlib_hooks();
|
init_vstdlib_hooks();
|
||||||
}
|
}
|
||||||
|
init_count++;
|
||||||
} else if (name == STEAMCLIENT_DLL) {
|
} else if (name == STEAMCLIENT_DLL) {
|
||||||
// SteamClient DLL handles unlocking functions
|
// SteamClient DLL handles unlocking functions
|
||||||
init_steamclient_hooks();
|
init_steamclient_hooks();
|
||||||
|
init_count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (init_count == 2) {
|
||||||
|
dll_monitor::shutdown();
|
||||||
}
|
}
|
||||||
} catch (const Exception& ex) {
|
} catch (const Exception& ex) {
|
||||||
logger->error("Koalageddon mode dll monitor init error. Module: '{}', Message: {}", name, ex.what());
|
logger->error("Koalageddon mode dll monitor init error. Module: '{}', Message: {}", name, ex.what());
|
||||||
|
|||||||
@@ -255,6 +255,7 @@ namespace koalageddon {
|
|||||||
DETOUR(SteamClient_Interface_Interceptor, interface_interceptor_address)
|
DETOUR(SteamClient_Interface_Interceptor, interface_interceptor_address)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ namespace smoke_api {
|
|||||||
DETOUR_ORIGINAL(CreateInterface)
|
DETOUR_ORIGINAL(CreateInterface)
|
||||||
});
|
});
|
||||||
|
|
||||||
// Hooking steam_api has show itself to be less desirable than steamclient
|
// Hooking steam_api has shown itself to be less desirable than steamclient
|
||||||
// for the reasons outlined below:
|
// for the reasons outlined below:
|
||||||
//
|
//
|
||||||
// Calling original in flat functions will actually call the hooked functions
|
// Calling original in flat functions will actually call the hooked functions
|
||||||
|
|||||||
@@ -70,7 +70,6 @@ DLL_EXPORT(void*) SteamUser() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DLL_EXPORT(void*) SteamInventory() {
|
DLL_EXPORT(void*) SteamInventory() {
|
||||||
static auto version = get_versioned_interface(STEAM_INVENTORY, "001");
|
static auto version = get_versioned_interface(STEAM_INVENTORY, "001");
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,4 @@
|
|||||||
#include <smoke_api/smoke_api.hpp>
|
#include <steam_impl/steam_client.hpp>
|
||||||
#include <steam_functions/steam_functions.hpp>
|
|
||||||
|
|
||||||
using namespace smoke_api;
|
|
||||||
|
|
||||||
namespace steam_client {
|
namespace steam_client {
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
#include <smoke_api/smoke_api.hpp>
|
#include <smoke_api/smoke_api.hpp>
|
||||||
#include <steam_functions/steam_functions.hpp>
|
#include <steam_functions/steam_functions.hpp>
|
||||||
|
|
||||||
using namespace smoke_api;
|
|
||||||
|
|
||||||
namespace steam_client {
|
namespace steam_client {
|
||||||
|
using namespace smoke_api;
|
||||||
|
|
||||||
void* GetGenericInterface(
|
void* GetGenericInterface(
|
||||||
const String& function_name,
|
const String& function_name,
|
||||||
|
|||||||
Reference in New Issue
Block a user