mirror of
https://github.com/acidicoala/SmokeAPI.git
synced 2025-12-06 05:25:43 -05:00
Reworked hooking
This commit is contained in:
@@ -37,6 +37,7 @@ namespace smoke_api::config {
|
||||
Config,
|
||||
$version,
|
||||
logging,
|
||||
log_steam_http,
|
||||
default_app_status,
|
||||
override_app_status,
|
||||
override_dlc_status,
|
||||
|
||||
@@ -4,9 +4,9 @@ std::vector<DLC> DLC::get_dlcs_from_apps(const AppDlcNameMap& apps, const AppId_
|
||||
std::vector<DLC> dlcs;
|
||||
|
||||
if(const auto app_id_str = std::to_string(app_id); apps.contains(app_id_str)) {
|
||||
const auto& app = apps.at(app_id_str);
|
||||
const auto& [app_dlcs] = apps.at(app_id_str);
|
||||
|
||||
for(auto const& [id, name] : app.dlcs) {
|
||||
for(auto const& [id, name] : app_dlcs) {
|
||||
dlcs.emplace_back(id, name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,16 +13,12 @@
|
||||
|
||||
// These macros are meant to be used for callbacks that should return original result
|
||||
|
||||
#define HOOKED_CALL(FUNC, ...) \
|
||||
static const auto _##FUNC = KB_HOOK_GET_HOOKED_FN(FUNC); \
|
||||
#define SWAPPED_CALL(CLASS, FUNC, ...) \
|
||||
const auto _##FUNC = KB_HOOK_GET_SWAPPED_FN(CLASS, FUNC); \
|
||||
return _##FUNC(__VA_ARGS__)
|
||||
|
||||
#define HOOKED_CALL_CLOSURE(FUNC, ...) \
|
||||
[&] { HOOKED_CALL(FUNC, __VA_ARGS__); }
|
||||
|
||||
#define HOOKED_CALL_RESULT(FUNC, ...) \
|
||||
static const auto _##FUNC = KB_HOOK_GET_HOOKED_FN(FUNC); \
|
||||
const auto result = _##FUNC(__VA_ARGS__)
|
||||
#define SWAPPED_CALL_CLOSURE(FUNC, ...) \
|
||||
[&] { SWAPPED_CALL(THIS, FUNC, __VA_ARGS__); }
|
||||
|
||||
/**
|
||||
* By default, virtual functions are declared with __thiscall
|
||||
|
||||
Reference in New Issue
Block a user