diff --git a/CMakeLists.txt b/CMakeLists.txt index 47def27..da770b1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.24) -project(SmokeAPI VERSION 2.0.2) +project(SmokeAPI VERSION 2.0.3) include(KoalaBox/cmake/KoalaBox.cmake) diff --git a/src/common/app_cache.cpp b/src/common/app_cache.cpp index 93a5d59..7be2bd2 100644 --- a/src/common/app_cache.cpp +++ b/src/common/app_cache.cpp @@ -7,12 +7,9 @@ constexpr auto KEY_APPS = "apps"; AppDlcNameMap get_cached_apps() noexcept { try { - const auto cache = koalabox::cache::read_from_cache(KEY_APPS); - - return cache.get(); + return koalabox::cache::get(KEY_APPS).get(); } catch (const Exception& e) { LOG_WARN("Failed to get cached apps: {}", e.what()) - 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)}; - return koalabox::cache::save_to_cache(KEY_APPS, Json(apps)); + return koalabox::cache::put(KEY_APPS, Json(apps)); } catch (const Exception& e) { LOG_ERROR("Error saving DLCs to disk cache: {}", e.what()) diff --git a/src/core/api.cpp b/src/core/api.cpp index 96b74a8..dee51cc 100644 --- a/src/core/api.cpp +++ b/src/core/api.cpp @@ -15,7 +15,7 @@ namespace api { try { const auto* url = "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(); return DLC::get_dlcs_from_apps(response, app_id); @@ -30,7 +30,7 @@ namespace api { // 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 json = koalabox::http_client::fetch_json(url); + const auto json = koalabox::http_client::get_json(url); const auto response = json.get(); diff --git a/src/core/globals.cpp b/src/core/globals.cpp index a4f3a35..b774471 100644 --- a/src/core/globals.cpp +++ b/src/core/globals.cpp @@ -1,11 +1,8 @@ -#include - namespace globals { - // TODO: Refactor to koalabox? + HMODULE smokeapi_handle = nullptr; HMODULE steamapi_module = nullptr; HMODULE vstdlib_module = nullptr; HMODULE steamclient_module = nullptr; - Map address_map; // NOLINT(cert-err58-cpp) } diff --git a/src/core/globals.hpp b/src/core/globals.hpp index 74608a7..b0a21aa 100644 --- a/src/core/globals.hpp +++ b/src/core/globals.hpp @@ -8,6 +8,5 @@ namespace globals { extern HMODULE steamclient_module; extern HMODULE steamapi_module; extern HMODULE vstdlib_module; - extern Map address_map; } diff --git a/src/core/types.hpp b/src/core/types.hpp index 60f7269..b987693 100644 --- a/src/core/types.hpp +++ b/src/core/types.hpp @@ -45,17 +45,17 @@ #define VIRTUAL(TYPE) __declspec(noinline) TYPE __fastcall #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) \ static const auto FUNC##_o = koalabox::hook::get_original_function(globals::steamapi_module, #FUNC, FUNC); #define DETOUR_ADDRESS(FUNC, ADDRESS) \ - koalabox::hook::detour_or_warn(globals::address_map, ADDRESS, #FUNC, reinterpret_cast(FUNC)); + koalabox::hook::detour_or_warn(ADDRESS, #FUNC, reinterpret_cast(FUNC)); #define $DETOUR(FUNC, NAME, MODULE_HANDLE) \ - koalabox::hook::detour_or_warn(globals::address_map, MODULE_HANDLE, NAME, reinterpret_cast(FUNC)); + koalabox::hook::detour_or_warn(MODULE_HANDLE, NAME, reinterpret_cast(FUNC)); #define DETOUR_STEAMCLIENT(FUNC) $DETOUR(FUNC, #FUNC, globals::steamclient_module) #define DETOUR_VSTDLIB(FUNC) $DETOUR(vstdlib::FUNC, #FUNC, globals::vstdlib_module) diff --git a/src/smoke_api/smoke_api.cpp b/src/smoke_api/smoke_api.cpp index 7bd98ec..267f81a 100644 --- a/src/smoke_api/smoke_api.cpp +++ b/src/smoke_api/smoke_api.cpp @@ -7,11 +7,9 @@ #include #include #include -#include #include #include #include -//#include #if COMPILE_STORE_MODE #include @@ -93,8 +91,6 @@ namespace smoke_api { // time stamp only when this file gets recompiled. 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_name = exe_path.filename().string(); diff --git a/src/steam_impl/steam_impl.cpp b/src/steam_impl/steam_impl.cpp index 7af8164..20a48bc 100644 --- a/src/steam_impl/steam_impl.cpp +++ b/src/steam_impl/steam_impl.cpp @@ -1,7 +1,7 @@ +#include #include #include #include -#include #include #include #include @@ -21,7 +21,7 @@ namespace steam_impl { { {6, 16}, {7, 18}, - {8, 15}, + {8, 15}, {9, 16}, {12, 15}, } @@ -114,9 +114,7 @@ namespace steam_impl { int get_ordinal(const FunctionOrdinalMap& ordinal_map, const String& function_name, int interface_version) { const auto& map = ordinal_map.at(function_name); - for (auto it = map.rbegin(); it != map.rend(); it++) { - const auto [version, ordinal] = *it; - + for (auto [version, ordinal]: std::ranges::reverse_view(map)) { if (interface_version >= version) { return ordinal; } @@ -127,7 +125,6 @@ namespace steam_impl { #define HOOK_VIRTUALS(MAP, FUNC) \ koalabox::hook::swap_virtual_func( \ - globals::address_map, \ interface, \ #FUNC, \ get_ordinal(MAP, #FUNC, version_number), \