mirror of
https://github.com/acidicoala/SmokeAPI.git
synced 2026-01-25 14:02:55 -05:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d9f477898c | ||
|
|
3c707f2474 | ||
|
|
e1987515d8 | ||
|
|
feb212e841 | ||
|
|
98c61f6e46 | ||
|
|
6b9cb115c3 |
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@@ -4,7 +4,7 @@ on: push
|
|||||||
jobs:
|
jobs:
|
||||||
ci:
|
ci:
|
||||||
name: CI
|
name: CI
|
||||||
uses: acidicoala/KoalaBox/.github/workflows/build-and-package.yml@15d5cfc2e515bc72e47da6c0c563820cff98551f
|
uses: acidicoala/KoalaBox/.github/workflows/build-and-package.yml@acac7a4450414784f441dc55c52758f550f182ab
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
with:
|
with:
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
cmake_minimum_required(VERSION 3.24)
|
cmake_minimum_required(VERSION 3.24)
|
||||||
|
|
||||||
project(SmokeAPI VERSION 2.0.2)
|
project(SmokeAPI VERSION 2.0.3)
|
||||||
|
|
||||||
include(KoalaBox/cmake/KoalaBox.cmake)
|
include(KoalaBox/cmake/KoalaBox.cmake)
|
||||||
|
|
||||||
@@ -28,7 +28,7 @@ configure_linker_exports(
|
|||||||
FORWARDED_DLL "${STEAMAPI_DLL}_o"
|
FORWARDED_DLL "${STEAMAPI_DLL}_o"
|
||||||
INPUT_SOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src/game_mode/exports"
|
INPUT_SOURCES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src/game_mode/exports"
|
||||||
INPUT_DLLS "${DLL_INPUT}"
|
INPUT_DLLS "${DLL_INPUT}"
|
||||||
DEP_SOURCES "${STEAM_API_EXPORTS}" # Is this redundant?
|
DEP_SOURCES "${STEAM_API_EXPORTS}"
|
||||||
)
|
)
|
||||||
|
|
||||||
configure_build_config(extra_build_config)
|
configure_build_config(extra_build_config)
|
||||||
|
|||||||
2
KoalaBox
2
KoalaBox
Submodule KoalaBox updated: fe45f9c61c...acac7a4450
@@ -140,7 +140,8 @@ The configuration file is expected to conform to the Json standard.
|
|||||||
Type::: Boolean
|
Type::: Boolean
|
||||||
Default::: `false`
|
Default::: `false`
|
||||||
|
|
||||||
`unlock_family_sharing`:: Toggles Family Sharing bypass, which enables the borrower of a shared library to start and continue playing games when library owner is playing as well.
|
`unlock_family_sharing`:: *_Store mode only_*.
|
||||||
|
Toggles Family Sharing bypass, which enables the borrower of a shared library to start and continue playing games when library owner is playing as well.
|
||||||
+
|
+
|
||||||
[horizontal]
|
[horizontal]
|
||||||
Type::: Boolean
|
Type::: Boolean
|
||||||
@@ -203,7 +204,8 @@ The format is the same as in the aforementioned GitHub config.
|
|||||||
Type::: Object (Map of String to Object)
|
Type::: Object (Map of String to Object)
|
||||||
Default::: `{}`
|
Default::: `{}`
|
||||||
|
|
||||||
`store_config`:: An object that specifies offsets required for store mode operation.
|
`store_config`:: *_Store mode only_*.
|
||||||
|
An object that specifies offsets required for store mode operation.
|
||||||
It will override the config fetched from {steam_config}[remote source] or local cache.
|
It will override the config fetched from {steam_config}[remote source] or local cache.
|
||||||
Do not modify this value unless you know what you are doing.
|
Do not modify this value unless you know what you are doing.
|
||||||
+
|
+
|
||||||
|
|||||||
@@ -7,12 +7,9 @@ constexpr auto KEY_APPS = "apps";
|
|||||||
|
|
||||||
AppDlcNameMap get_cached_apps() noexcept {
|
AppDlcNameMap get_cached_apps() noexcept {
|
||||||
try {
|
try {
|
||||||
const auto cache = koalabox::cache::read_from_cache(KEY_APPS);
|
return koalabox::cache::get(KEY_APPS).get<AppDlcNameMap>();
|
||||||
|
|
||||||
return cache.get<AppDlcNameMap>();
|
|
||||||
} catch (const Exception& e) {
|
} catch (const Exception& e) {
|
||||||
LOG_WARN("Failed to get cached apps: {}", e.what())
|
LOG_WARN("Failed to get cached apps: {}", e.what())
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -41,7 +38,7 @@ namespace smoke_api::app_cache {
|
|||||||
|
|
||||||
apps[std::to_string(app_id)] = App{.dlcs=DLC::get_dlc_map_from_vector(dlcs)};
|
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));
|
return koalabox::cache::put(KEY_APPS, Json(apps));
|
||||||
} catch (const Exception& e) {
|
} catch (const Exception& e) {
|
||||||
LOG_ERROR("Error saving DLCs to disk cache: {}", e.what())
|
LOG_ERROR("Error saving DLCs to disk cache: {}", e.what())
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ namespace api {
|
|||||||
try {
|
try {
|
||||||
const auto* url =
|
const auto* url =
|
||||||
"https://raw.githubusercontent.com/acidicoala/public-entitlements/main/steam/v2/dlc.json";
|
"https://raw.githubusercontent.com/acidicoala/public-entitlements/main/steam/v2/dlc.json";
|
||||||
const auto json = koalabox::http_client::fetch_json(url);
|
const auto json = koalabox::http_client::get_json(url);
|
||||||
const auto response = json.get<AppDlcNameMap>();
|
const auto response = json.get<AppDlcNameMap>();
|
||||||
|
|
||||||
return DLC::get_dlcs_from_apps(response, app_id);
|
return DLC::get_dlcs_from_apps(response, app_id);
|
||||||
@@ -27,8 +27,10 @@ namespace api {
|
|||||||
|
|
||||||
std::optional<Vector<DLC>> fetch_dlcs_from_steam(AppId_t app_id) noexcept {
|
std::optional<Vector<DLC>> fetch_dlcs_from_steam(AppId_t app_id) noexcept {
|
||||||
try {
|
try {
|
||||||
|
// TODO: Communicate directly with Steam servers.
|
||||||
|
// ref.: https://github.com/SteamRE/SteamKit
|
||||||
const auto url = fmt::format("https://store.steampowered.com/dlc/{}/ajaxgetdlclist", app_id);
|
const auto url = fmt::format("https://store.steampowered.com/dlc/{}/ajaxgetdlclist", app_id);
|
||||||
const auto json = koalabox::http_client::fetch_json(url);
|
const auto json = koalabox::http_client::get_json(url);
|
||||||
|
|
||||||
const auto response = json.get<SteamResponse>();
|
const auto response = json.get<SteamResponse>();
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,8 @@
|
|||||||
#include <core/globals.hpp>
|
|
||||||
|
|
||||||
namespace globals {
|
namespace globals {
|
||||||
// TODO: Refactor to koalabox?
|
|
||||||
HMODULE smokeapi_handle = nullptr;
|
HMODULE smokeapi_handle = nullptr;
|
||||||
HMODULE steamapi_module = nullptr;
|
HMODULE steamapi_module = nullptr;
|
||||||
HMODULE vstdlib_module = nullptr;
|
HMODULE vstdlib_module = nullptr;
|
||||||
HMODULE steamclient_module = nullptr;
|
HMODULE steamclient_module = nullptr;
|
||||||
Map<String, uintptr_t> address_map; // NOLINT(cert-err58-cpp)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,5 @@ namespace globals {
|
|||||||
extern HMODULE steamclient_module;
|
extern HMODULE steamclient_module;
|
||||||
extern HMODULE steamapi_module;
|
extern HMODULE steamapi_module;
|
||||||
extern HMODULE vstdlib_module;
|
extern HMODULE vstdlib_module;
|
||||||
extern Map<String, uintptr_t> address_map;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,17 +45,17 @@
|
|||||||
#define VIRTUAL(TYPE) __declspec(noinline) TYPE __fastcall
|
#define VIRTUAL(TYPE) __declspec(noinline) TYPE __fastcall
|
||||||
|
|
||||||
#define GET_ORIGINAL_HOOKED_FUNCTION(FUNC) \
|
#define GET_ORIGINAL_HOOKED_FUNCTION(FUNC) \
|
||||||
static const auto FUNC##_o = koalabox::hook::get_original_hooked_function(globals::address_map, #FUNC, FUNC);
|
static const auto FUNC##_o = koalabox::hook::get_original_hooked_function(#FUNC, FUNC);
|
||||||
|
|
||||||
#define GET_ORIGINAL_FUNCTION_STEAMAPI(FUNC) \
|
#define GET_ORIGINAL_FUNCTION_STEAMAPI(FUNC) \
|
||||||
static const auto FUNC##_o = koalabox::hook::get_original_function(globals::steamapi_module, #FUNC, FUNC);
|
static const auto FUNC##_o = koalabox::hook::get_original_function(globals::steamapi_module, #FUNC, FUNC);
|
||||||
|
|
||||||
|
|
||||||
#define DETOUR_ADDRESS(FUNC, ADDRESS) \
|
#define DETOUR_ADDRESS(FUNC, ADDRESS) \
|
||||||
koalabox::hook::detour_or_warn(globals::address_map, ADDRESS, #FUNC, reinterpret_cast<uintptr_t>(FUNC));
|
koalabox::hook::detour_or_warn(ADDRESS, #FUNC, reinterpret_cast<uintptr_t>(FUNC));
|
||||||
|
|
||||||
#define $DETOUR(FUNC, NAME, MODULE_HANDLE) \
|
#define $DETOUR(FUNC, NAME, MODULE_HANDLE) \
|
||||||
koalabox::hook::detour_or_warn(globals::address_map, MODULE_HANDLE, NAME, reinterpret_cast<uintptr_t>(FUNC));
|
koalabox::hook::detour_or_warn(MODULE_HANDLE, NAME, reinterpret_cast<uintptr_t>(FUNC));
|
||||||
|
|
||||||
#define DETOUR_STEAMCLIENT(FUNC) $DETOUR(FUNC, #FUNC, globals::steamclient_module)
|
#define DETOUR_STEAMCLIENT(FUNC) $DETOUR(FUNC, #FUNC, globals::steamclient_module)
|
||||||
#define DETOUR_VSTDLIB(FUNC) $DETOUR(vstdlib::FUNC, #FUNC, globals::vstdlib_module)
|
#define DETOUR_VSTDLIB(FUNC) $DETOUR(vstdlib::FUNC, #FUNC, globals::vstdlib_module)
|
||||||
|
|||||||
@@ -4,14 +4,13 @@
|
|||||||
#include <core/globals.hpp>
|
#include <core/globals.hpp>
|
||||||
#include <core/paths.hpp>
|
#include <core/paths.hpp>
|
||||||
#include <common/steamclient_exports.hpp>
|
#include <common/steamclient_exports.hpp>
|
||||||
|
#include <koalabox/globals.hpp>
|
||||||
#include <koalabox/dll_monitor.hpp>
|
#include <koalabox/dll_monitor.hpp>
|
||||||
#include <koalabox/logger.hpp>
|
#include <koalabox/logger.hpp>
|
||||||
#include <koalabox/hook.hpp>
|
#include <koalabox/hook.hpp>
|
||||||
#include <koalabox/cache.hpp>
|
|
||||||
#include <koalabox/loader.hpp>
|
#include <koalabox/loader.hpp>
|
||||||
#include <koalabox/win_util.hpp>
|
#include <koalabox/win_util.hpp>
|
||||||
#include <koalabox/util.hpp>
|
#include <koalabox/util.hpp>
|
||||||
//#include <steam_api_exports/steam_api_exports.hpp>
|
|
||||||
|
|
||||||
#if COMPILE_STORE_MODE
|
#if COMPILE_STORE_MODE
|
||||||
#include <store_mode/store.hpp>
|
#include <store_mode/store.hpp>
|
||||||
@@ -81,6 +80,8 @@ namespace smoke_api {
|
|||||||
try {
|
try {
|
||||||
DisableThreadLibraryCalls(module_handle);
|
DisableThreadLibraryCalls(module_handle);
|
||||||
|
|
||||||
|
koalabox::globals::init_globals(module_handle, PROJECT_NAME);
|
||||||
|
|
||||||
globals::smokeapi_handle = module_handle;
|
globals::smokeapi_handle = module_handle;
|
||||||
|
|
||||||
config::init_config();
|
config::init_config();
|
||||||
@@ -93,8 +94,6 @@ namespace smoke_api {
|
|||||||
// time stamp only when this file gets recompiled.
|
// time stamp only when this file gets recompiled.
|
||||||
LOG_INFO("🐨 {} v{} | Compiled at '{}'", PROJECT_NAME, PROJECT_VERSION, __TIMESTAMP__)
|
LOG_INFO("🐨 {} v{} | Compiled at '{}'", PROJECT_NAME, PROJECT_VERSION, __TIMESTAMP__)
|
||||||
|
|
||||||
koalabox::cache::init_cache(paths::get_cache_path());
|
|
||||||
|
|
||||||
const auto exe_path = Path(koalabox::win_util::get_module_file_name_or_throw(nullptr));
|
const auto exe_path = Path(koalabox::win_util::get_module_file_name_or_throw(nullptr));
|
||||||
const auto exe_name = exe_path.filename().string();
|
const auto exe_name = exe_path.filename().string();
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
|
#include <ranges>
|
||||||
#include <steam_impl/steam_impl.hpp>
|
#include <steam_impl/steam_impl.hpp>
|
||||||
#include <game_mode/virtuals/steam_api_virtuals.hpp>
|
#include <game_mode/virtuals/steam_api_virtuals.hpp>
|
||||||
#include <common/steamclient_exports.hpp>
|
#include <common/steamclient_exports.hpp>
|
||||||
#include <core/globals.hpp>
|
|
||||||
#include <build_config.h>
|
#include <build_config.h>
|
||||||
#include <koalabox/util.hpp>
|
#include <koalabox/util.hpp>
|
||||||
#include <koalabox/win_util.hpp>
|
#include <koalabox/win_util.hpp>
|
||||||
@@ -21,7 +21,7 @@ namespace steam_impl {
|
|||||||
{
|
{
|
||||||
{6, 16},
|
{6, 16},
|
||||||
{7, 18},
|
{7, 18},
|
||||||
{8, 15},
|
{8, 15},
|
||||||
{9, 16},
|
{9, 16},
|
||||||
{12, 15},
|
{12, 15},
|
||||||
}
|
}
|
||||||
@@ -114,9 +114,7 @@ namespace steam_impl {
|
|||||||
int get_ordinal(const FunctionOrdinalMap& ordinal_map, const String& function_name, int interface_version) {
|
int get_ordinal(const FunctionOrdinalMap& ordinal_map, const String& function_name, int interface_version) {
|
||||||
const auto& map = ordinal_map.at(function_name);
|
const auto& map = ordinal_map.at(function_name);
|
||||||
|
|
||||||
for (auto it = map.rbegin(); it != map.rend(); it++) {
|
for (auto [version, ordinal]: std::ranges::reverse_view(map)) {
|
||||||
const auto [version, ordinal] = *it;
|
|
||||||
|
|
||||||
if (interface_version >= version) {
|
if (interface_version >= version) {
|
||||||
return ordinal;
|
return ordinal;
|
||||||
}
|
}
|
||||||
@@ -127,7 +125,6 @@ namespace steam_impl {
|
|||||||
|
|
||||||
#define HOOK_VIRTUALS(MAP, FUNC) \
|
#define HOOK_VIRTUALS(MAP, FUNC) \
|
||||||
koalabox::hook::swap_virtual_func( \
|
koalabox::hook::swap_virtual_func( \
|
||||||
globals::address_map, \
|
|
||||||
interface, \
|
interface, \
|
||||||
#FUNC, \
|
#FUNC, \
|
||||||
get_ordinal(MAP, #FUNC, version_number), \
|
get_ordinal(MAP, #FUNC, version_number), \
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ namespace store::steamclient {
|
|||||||
construct_ordinal_map(#INTERFACE, ordinal_map[#INTERFACE], function_selector_address);
|
construct_ordinal_map(#INTERFACE, ordinal_map[#INTERFACE], function_selector_address);
|
||||||
|
|
||||||
#define HOOK_FUNCTION(INTERFACE, FUNC) hook::swap_virtual_func_or_throw( \
|
#define HOOK_FUNCTION(INTERFACE, FUNC) hook::swap_virtual_func_or_throw( \
|
||||||
globals::address_map, \
|
|
||||||
interface, \
|
interface, \
|
||||||
#INTERFACE"_"#FUNC, \
|
#INTERFACE"_"#FUNC, \
|
||||||
ordinal_map[#INTERFACE][#FUNC], \
|
ordinal_map[#INTERFACE][#FUNC], \
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ namespace store::api {
|
|||||||
try {
|
try {
|
||||||
const String url =
|
const String url =
|
||||||
"https://raw.githubusercontent.com/acidicoala/public-entitlements/main/steam/v2/store_config.json";
|
"https://raw.githubusercontent.com/acidicoala/public-entitlements/main/steam/v2/store_config.json";
|
||||||
const auto kg_config_json = koalabox::http_client::fetch_json(url);
|
const auto kg_config_json = koalabox::http_client::get_json(url);
|
||||||
|
|
||||||
return kg_config_json.get<StoreConfig>();
|
return kg_config_json.get<StoreConfig>();
|
||||||
} catch (const Exception& e) {
|
} catch (const Exception& e) {
|
||||||
|
|||||||
@@ -7,9 +7,7 @@ namespace store::store_cache {
|
|||||||
|
|
||||||
std::optional<StoreConfig> get_store_config() {
|
std::optional<StoreConfig> get_store_config() {
|
||||||
try {
|
try {
|
||||||
const auto config_json = koalabox::cache::read_from_cache(KEY_KG_CONFIG);
|
return koalabox::cache::get(KEY_KG_CONFIG, Json(nullptr)).get<StoreConfig>();
|
||||||
|
|
||||||
return config_json.get<StoreConfig>();
|
|
||||||
} catch (const Exception& e) {
|
} catch (const Exception& e) {
|
||||||
LOG_ERROR("Failed to get cached store_mode config: {}", e.what())
|
LOG_ERROR("Failed to get cached store_mode config: {}", e.what())
|
||||||
|
|
||||||
@@ -21,7 +19,7 @@ namespace store::store_cache {
|
|||||||
try {
|
try {
|
||||||
LOG_DEBUG("Caching store_mode config")
|
LOG_DEBUG("Caching store_mode config")
|
||||||
|
|
||||||
return koalabox::cache::save_to_cache(KEY_KG_CONFIG, Json(config));
|
return koalabox::cache::put(KEY_KG_CONFIG, Json(config));
|
||||||
} catch (const Exception& e) {
|
} catch (const Exception& e) {
|
||||||
LOG_ERROR("Failed to cache store_mode config: {}", e.what())
|
LOG_ERROR("Failed to cache store_mode config: {}", e.what())
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user