Split static & shared lib

This commit is contained in:
acidicoala
2025-08-23 13:44:17 +05:00
parent b828ecc58a
commit dc086e40e0
48 changed files with 1048 additions and 1318 deletions

View File

@@ -0,0 +1,79 @@
#include <koalabox/logger.hpp>
#include "smoke_api.hpp"
#include "smoke_api/interfaces/steam_apps.hpp"
#include "steam_api/steam_interface.hpp"
#include "steam_api/virtuals/steam_api_virtuals.hpp"
VIRTUAL(bool) ISteamApps_BIsSubscribedApp(PARAMS(const AppId_t dlc_id)) {
try {
return smoke_api::steam_apps::IsDlcUnlocked(
__func__,
steam_interface::get_app_id(),
dlc_id,
HOOKED_CALL_CLOSURE(ISteamApps_BIsSubscribedApp, ARGS(dlc_id))
);
} catch(const std::exception& e) {
LOG_ERROR("{} -> Error: {}", __func__, e.what());
return false;
}
}
VIRTUAL(bool) ISteamApps_BIsDlcInstalled(PARAMS(const AppId_t dlc_id)) {
try {
return smoke_api::steam_apps::IsDlcUnlocked(
__func__,
steam_interface::get_app_id(),
dlc_id,
HOOKED_CALL_CLOSURE(ISteamApps_BIsDlcInstalled, ARGS(dlc_id))
);
} catch(const std::exception& e) {
LOG_ERROR("{} -> Error: {}", __func__, e.what());
return false;
}
}
VIRTUAL(int) ISteamApps_GetDLCCount(PARAMS()) {
try {
return smoke_api::steam_apps::GetDLCCount(
__func__,
steam_interface::get_app_id(),
HOOKED_CALL_CLOSURE(ISteamApps_GetDLCCount, ARGS())
);
} catch(const std::exception& e) {
LOG_ERROR("{} -> Error: {}", __func__, e.what());
return 0;
}
}
VIRTUAL(bool) ISteamApps_BGetDLCDataByIndex(
PARAMS(
const int iDLC,
AppId_t* p_dlc_id,
bool* pbAvailable,
char* pchName,
const int cchNameBufferSize
)
) {
try {
return smoke_api::steam_apps::GetDLCDataByIndex(
__func__,
steam_interface::get_app_id(),
iDLC,
p_dlc_id,
pbAvailable,
pchName,
cchNameBufferSize,
HOOKED_CALL_CLOSURE(
ISteamApps_BGetDLCDataByIndex,
ARGS(iDLC, p_dlc_id, pbAvailable, pchName, cchNameBufferSize)
),
[&](const AppId_t dlc_id) {
return ISteamApps_BIsDlcInstalled(ARGS(dlc_id));
}
);
} catch(const std::exception& e) {
LOG_ERROR("{} -> Error: {}", __func__, e.what());
return false;
}
}

View File

@@ -0,0 +1,87 @@
#include <koalabox/logger.hpp>
#include "smoke_api.hpp"
#include "steam_api/steam_client.hpp"
#include "steam_api/virtuals/steam_api_virtuals.hpp"
VIRTUAL(void*) ISteamClient_GetISteamApps(
PARAMS(
const HSteamUser hSteamUser,
const HSteamPipe hSteamPipe,
const char* version
)
) {
try {
return steam_client::GetGenericInterface(
__func__,
version,
HOOKED_CALL_CLOSURE(ISteamClient_GetISteamApps, ARGS(hSteamUser, hSteamPipe, version))
);
} catch(const std::exception& e) {
LOG_ERROR("{} -> Error: {}", __func__, e.what());
return nullptr;
}
}
VIRTUAL(void*) ISteamClient_GetISteamUser(
PARAMS(
const HSteamUser hSteamUser,
const HSteamPipe hSteamPipe,
const char* version
)
) {
try {
return steam_client::GetGenericInterface(
__func__,
version,
HOOKED_CALL_CLOSURE(ISteamClient_GetISteamUser, ARGS(hSteamUser, hSteamPipe, version))
);
} catch(const std::exception& e) {
LOG_ERROR("{} -> Error: {}", __func__, e.what());
return nullptr;
}
}
VIRTUAL(void*) ISteamClient_GetISteamGenericInterface(
PARAMS(
HSteamUser hSteamUser,
HSteamPipe hSteamPipe,
const char* pchVersion
)
) {
try {
return steam_client::GetGenericInterface(
__func__,
pchVersion,
HOOKED_CALL_CLOSURE(
ISteamClient_GetISteamGenericInterface,
ARGS(hSteamUser, hSteamPipe, pchVersion)
)
);
} catch(const std::exception& e) {
LOG_ERROR("{} -> Error: {}", __func__, e.what());
return nullptr;
}
}
VIRTUAL(void*) ISteamClient_GetISteamInventory(
PARAMS(
const HSteamUser hSteamUser,
const HSteamPipe hSteamPipe,
const char* pchVersion
)
) {
try {
return steam_client::GetGenericInterface(
__func__,
pchVersion,
HOOKED_CALL_CLOSURE(
ISteamClient_GetISteamInventory,
ARGS(hSteamUser, hSteamPipe, pchVersion)
)
);
} catch(const std::exception& e) {
LOG_ERROR("{} -> Error: {}", __func__, e.what());
return nullptr;
}
}

View File

@@ -0,0 +1,144 @@
#include "smoke_api.hpp"
#include "smoke_api/interfaces/steam_inventory.hpp"
#include "steam_api/virtuals/steam_api_virtuals.hpp"
VIRTUAL(EResult) ISteamInventory_GetResultStatus(
PARAMS(const SteamInventoryResult_t resultHandle)
) {
return smoke_api::steam_inventory::GetResultStatus(
__func__,
resultHandle,
HOOKED_CALL_CLOSURE(ISteamInventory_GetResultStatus, ARGS(resultHandle))
);
}
VIRTUAL(bool) ISteamInventory_GetResultItems(
PARAMS(
const SteamInventoryResult_t resultHandle,
SteamItemDetails_t* pOutItemsArray,
uint32_t* punOutItemsArraySize
)
) {
return smoke_api::steam_inventory::GetResultItems(
__func__,
resultHandle,
pOutItemsArray,
punOutItemsArraySize,
HOOKED_CALL_CLOSURE(
ISteamInventory_GetResultItems,
ARGS(resultHandle, pOutItemsArray, punOutItemsArraySize)
),
[&](SteamItemDef_t* pItemDefIDs, uint32_t* punItemDefIDsArraySize) {
HOOKED_CALL(
ISteamInventory_GetItemDefinitionIDs,
ARGS(pItemDefIDs, punItemDefIDsArraySize)
);
}
);
}
VIRTUAL(bool) ISteamInventory_GetResultItemProperty(
PARAMS(
const SteamInventoryResult_t resultHandle,
const uint32_t unItemIndex,
const char* pchPropertyName,
char* pchValueBuffer,
uint32_t* punValueBufferSizeOut
)
) {
return smoke_api::steam_inventory::GetResultItemProperty(
__func__,
resultHandle,
unItemIndex,
pchPropertyName,
pchValueBuffer,
punValueBufferSizeOut,
HOOKED_CALL_CLOSURE(
ISteamInventory_GetResultItemProperty,
ARGS(
resultHandle,
unItemIndex,
pchPropertyName,
pchValueBuffer,
punValueBufferSizeOut
)
)
);
}
VIRTUAL(bool) ISteamInventory_GetAllItems(PARAMS(SteamInventoryResult_t* pResultHandle)) {
return smoke_api::steam_inventory::GetAllItems(
__func__,
pResultHandle,
HOOKED_CALL_CLOSURE(ISteamInventory_GetAllItems, ARGS(pResultHandle))
);
}
VIRTUAL(bool) ISteamInventory_GetItemsByID(
PARAMS(
SteamInventoryResult_t* pResultHandle,
const SteamItemInstanceID_t* pInstanceIDs,
const uint32_t unCountInstanceIDs
)
) {
return smoke_api::steam_inventory::GetItemsByID(
__func__,
pResultHandle,
pInstanceIDs,
unCountInstanceIDs,
HOOKED_CALL_CLOSURE(
ISteamInventory_GetItemsByID,
ARGS(pResultHandle, pInstanceIDs, unCountInstanceIDs)
)
);
}
VIRTUAL(bool) ISteamInventory_SerializeResult(
PARAMS(
const SteamInventoryResult_t resultHandle,
void* pOutBuffer,
uint32_t* punOutBufferSize
)
) {
return smoke_api::steam_inventory::SerializeResult(
__func__,
resultHandle,
pOutBuffer,
punOutBufferSize,
HOOKED_CALL_CLOSURE(
ISteamInventory_SerializeResult,
ARGS(resultHandle, pOutBuffer, punOutBufferSize)
)
);
}
VIRTUAL(bool) ISteamInventory_GetItemDefinitionIDs(
PARAMS(
SteamItemDef_t*pItemDefIDs,
uint32_t* punItemDefIDsArraySize
)
) {
return smoke_api::steam_inventory::GetItemDefinitionIDs(
__func__,
pItemDefIDs,
punItemDefIDsArraySize,
HOOKED_CALL_CLOSURE(
ISteamInventory_GetItemDefinitionIDs,
ARGS(pItemDefIDs, punItemDefIDsArraySize)
)
);
}
VIRTUAL(bool) ISteamInventory_CheckResultSteamID(
PARAMS(SteamInventoryResult_t resultHandle, CSteamID steamIDExpected)
) {
return smoke_api::steam_inventory::CheckResultSteamID(
__func__,
resultHandle,
steamIDExpected,
HOOKED_CALL_CLOSURE(
ISteamInventory_CheckResultSteamID,
ARGS(resultHandle, steamIDExpected)
)
);
}

View File

@@ -0,0 +1,23 @@
#include <koalabox/logger.hpp>
#include "smoke_api.hpp"
#include "smoke_api/interfaces/steam_user.hpp"
#include "steam_api/steam_interface.hpp"
#include "steam_api/virtuals/steam_api_virtuals.hpp"
VIRTUAL(EUserHasLicenseForAppResult) ISteamUser_UserHasLicenseForApp(
PARAMS(const CSteamID steamID, const AppId_t dlc_id)
) {
try {
static const auto app_id = steam_interface::get_app_id();
return smoke_api::steam_user::UserHasLicenseForApp(
__func__,
app_id,
dlc_id,
HOOKED_CALL_CLOSURE(ISteamUser_UserHasLicenseForApp, ARGS(steamID, dlc_id))
);
} catch(const std::exception& e) {
LOG_ERROR("{} -> Error: {}", __func__, e.what());
return k_EUserHasLicenseResultDoesNotHaveLicense;
}
}

View File

@@ -0,0 +1,70 @@
#pragma once
#include "smoke_api/types.hpp"
/**
* 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 our
* 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(...) 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
#define VIRTUAL(TYPE) __declspec(noinline) TYPE __fastcall // NOLINT(*-macro-parentheses)
// ISteamApps
VIRTUAL(bool) ISteamApps_BIsSubscribedApp(PARAMS(AppId_t));
VIRTUAL(bool) ISteamApps_BIsDlcInstalled(PARAMS(AppId_t));
VIRTUAL(int) ISteamApps_GetDLCCount(PARAMS());
VIRTUAL(bool) ISteamApps_BGetDLCDataByIndex(PARAMS(int, AppId_t*, bool*, char*, int));
// ISteamClient
VIRTUAL(void*) ISteamClient_GetISteamApps(PARAMS(HSteamUser, HSteamPipe, const char*));
VIRTUAL(void*) ISteamClient_GetISteamUser(PARAMS(HSteamUser, HSteamPipe, const char*));
VIRTUAL(void*) ISteamClient_GetISteamGenericInterface(PARAMS(HSteamUser, HSteamPipe, const char*));
VIRTUAL(void*) ISteamClient_GetISteamInventory(PARAMS(HSteamUser, HSteamPipe, const char*));
// ISteamInventory
VIRTUAL(EResult) ISteamInventory_GetResultStatus(PARAMS(SteamInventoryResult_t));
VIRTUAL(bool) ISteamInventory_GetResultItems(
PARAMS(SteamInventoryResult_t, SteamItemDetails_t*, uint32_t*) // @formatter:off
); // @formatter:on
VIRTUAL(bool) ISteamInventory_GetResultItemProperty(
PARAMS(SteamInventoryResult_t, uint32_t, const char*, char*, uint32_t*) // @formatter:off
); // @formatter:on
VIRTUAL(bool) ISteamInventory_GetAllItems(PARAMS(SteamInventoryResult_t*));
VIRTUAL(bool) ISteamInventory_GetItemsByID(
PARAMS(SteamInventoryResult_t*, const SteamItemInstanceID_t*, uint32_t)
);
VIRTUAL(bool) ISteamInventory_SerializeResult(PARAMS(SteamInventoryResult_t, void*, uint32_t*));
VIRTUAL(bool) ISteamInventory_GetItemDefinitionIDs(PARAMS(SteamItemDef_t*, uint32_t*));
VIRTUAL(bool) ISteamInventory_CheckResultSteamID(PARAMS(SteamInventoryResult_t, CSteamID));
// ISteamUser
VIRTUAL(EUserHasLicenseForAppResult) ISteamUser_UserHasLicenseForApp(PARAMS(CSteamID, AppId_t));