mirror of
https://github.com/acidicoala/SmokeAPI.git
synced 2025-12-05 21:15:39 -05:00
Refactored types
This commit is contained in:
@@ -23,7 +23,7 @@ namespace smoke_api::config {
|
||||
)
|
||||
|
||||
struct Config {
|
||||
uint32_t $version = 2;
|
||||
uint32_t $version = 3;
|
||||
bool logging = false;
|
||||
AppStatus default_app_status = AppStatus::UNLOCKED;
|
||||
uint32_t override_app_id = 0;
|
||||
|
||||
@@ -64,11 +64,11 @@ namespace smoke_api::steam_inventory {
|
||||
);
|
||||
|
||||
static uint32_t original_count = 0;
|
||||
const auto injected_count = smoke_api::config::instance.extra_inventory_items.size();
|
||||
const auto injected_count = config::instance.extra_inventory_items.size();
|
||||
|
||||
// Automatically get inventory items from steam
|
||||
static std::vector<SteamItemDef_t> auto_inventory_items;
|
||||
if(smoke_api::config::instance.auto_inject_inventory) {
|
||||
if(config::instance.auto_inject_inventory) {
|
||||
static std::once_flag inventory_inject_flag;
|
||||
std::call_once(
|
||||
inventory_inject_flag,
|
||||
@@ -120,7 +120,7 @@ namespace smoke_api::steam_inventory {
|
||||
|
||||
for(int i = 0; i < injected_count; i++) {
|
||||
auto& item = pOutItemsArray[original_count + auto_injected_count + i];
|
||||
const auto item_def_id = smoke_api::config::instance.extra_inventory_items[i];
|
||||
const auto item_def_id = config::instance.extra_inventory_items[i];
|
||||
|
||||
item = new_item(item_def_id);
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace smoke_api::steam_user {
|
||||
return result;
|
||||
}
|
||||
|
||||
const auto has_license = smoke_api::config::is_dlc_unlocked(
|
||||
const auto has_license = config::is_dlc_unlocked(
|
||||
appId,
|
||||
dlcId,
|
||||
[&] {
|
||||
|
||||
5
static/smoke_api/steamclient/steamclient.hpp
Normal file
5
static/smoke_api/steamclient/steamclient.hpp
Normal file
@@ -0,0 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include "smoke_api/types.hpp"
|
||||
|
||||
C_DECL(void*) CreateInterface(const char* interface_version, int* out_result);
|
||||
@@ -6,12 +6,52 @@
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
// TODO: Replace with direct call
|
||||
#define GET_ORIGINAL_HOOKED_FUNCTION(FUNC) \
|
||||
static const auto FUNC##_o = koalabox::hook::get_original_hooked_function(#FUNC, FUNC);
|
||||
#include <koalabox/hook.hpp>
|
||||
|
||||
#define DETOUR_ADDRESS(FUNC, ADDRESS) \
|
||||
koalabox::hook::detour_or_warn(ADDRESS, #FUNC, reinterpret_cast<uintptr_t>(FUNC));
|
||||
#define VIRTUAL(TYPE) __declspec(noinline) TYPE __fastcall // NOLINT(*-macro-parentheses)
|
||||
#define C_DECL(TYPE) extern "C" __declspec(noinline) TYPE __cdecl
|
||||
|
||||
// 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); \
|
||||
return _##FUNC(__VA_ARGS__)
|
||||
|
||||
#define HOOKED_CALL_CLOSURE(FUNC, ...) \
|
||||
[&] { HOOKED_CALL(FUNC, __VA_ARGS__); }
|
||||
|
||||
/**
|
||||
* By default, virtual functions are declared with __thiscall
|
||||
* convention, which is normal since they are class members.
|
||||
* But it presents an issue for us, since we cannot pass *this
|
||||
* pointer as a function argument. This is because *this
|
||||
* pointer is passed via register ECX in __thiscall
|
||||
* convention. Hence, to resolve this issue we declare virtual
|
||||
* hooked functions with __fastcall convention, to trick
|
||||
* the compiler into reading ECX & EDX registers as 1st
|
||||
* and 2nd function arguments respectively. Similarly, __fastcall
|
||||
* makes the compiler push the first argument into the ECX register,
|
||||
* which mimics the __thiscall calling convention. Register EDX
|
||||
* is not used anywhere in this case, but we still pass it along
|
||||
* to conform to the __fastcall convention. This all applies
|
||||
* to the x86 architecture.
|
||||
*
|
||||
* In x86-64 however, there is only one calling convention,
|
||||
* so __fastcall is simply ignored. However, RDX in this case
|
||||
* will store the 1st actual argument to the function, so we
|
||||
* have to omit it from the function signature.
|
||||
*
|
||||
* The macros below implement the above-mentioned considerations.
|
||||
*/
|
||||
#ifdef _WIN64
|
||||
#define PARAMS(...) const void *RCX, __VA_ARGS__
|
||||
#define ARGS(...) RCX, __VA_ARGS__
|
||||
#define THIS RCX
|
||||
#else
|
||||
#define PARAMS(...) const void *ECX, const void *EDX, __VA_ARGS__
|
||||
#define ARGS(...) ECX, EDX, __VA_ARGS__
|
||||
#define THIS ECX
|
||||
#endif
|
||||
|
||||
using AppId_t = uint32_t;
|
||||
using HSteamPipe = uint32_t;
|
||||
@@ -80,4 +120,4 @@ public:
|
||||
static std::vector<DLC> get_dlcs_from_apps(const AppDlcNameMap& apps, AppId_t app_id);
|
||||
|
||||
static DlcNameMap get_dlc_map_from_vector(const std::vector<DLC>& dlcs);
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user