mirror of
https://github.com/acidicoala/SmokeAPI.git
synced 2025-12-06 05:25:43 -05:00
Fixed Windows build
This commit is contained in:
@@ -39,6 +39,7 @@ set(SMOKE_API_SOURCES
|
|||||||
src/steam_api/virtuals/isteamhttp.cpp
|
src/steam_api/virtuals/isteamhttp.cpp
|
||||||
src/steam_api/virtuals/isteaminventory.cpp
|
src/steam_api/virtuals/isteaminventory.cpp
|
||||||
src/steam_api/virtuals/isteamuser.cpp
|
src/steam_api/virtuals/isteamuser.cpp
|
||||||
|
src/steam_api/virtuals/isteamutils.cpp
|
||||||
src/steam_api/virtuals/steam_api_virtuals.hpp
|
src/steam_api/virtuals/steam_api_virtuals.hpp
|
||||||
src/steam_api/steam_client.hpp
|
src/steam_api/steam_client.hpp
|
||||||
src/steam_api/steam_client.cpp
|
src/steam_api/steam_client.cpp
|
||||||
|
|||||||
2
KoalaBox
2
KoalaBox
Submodule KoalaBox updated: dbe840c569...30227ef32e
@@ -16,6 +16,7 @@
|
|||||||
#include "smoke_api/config.hpp"
|
#include "smoke_api/config.hpp"
|
||||||
#include "smoke_api/steamclient/steamclient.hpp"
|
#include "smoke_api/steamclient/steamclient.hpp"
|
||||||
#include "steam_api/steam_interfaces.hpp"
|
#include "steam_api/steam_interfaces.hpp"
|
||||||
|
#include "steam_api/virtuals/steam_api_virtuals.hpp"
|
||||||
|
|
||||||
#include "build_config.h"
|
#include "build_config.h"
|
||||||
|
|
||||||
@@ -179,14 +180,46 @@ namespace smoke_api {
|
|||||||
}
|
}
|
||||||
|
|
||||||
AppId_t get_app_id() {
|
AppId_t get_app_id() {
|
||||||
|
static AppId_t app_id = 0;
|
||||||
|
if(app_id) {
|
||||||
|
return app_id; // cached value
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const auto* const app_id_str = std::getenv("SteamAppId");
|
if(const auto app_id_str = kb::util::get_env("SteamAppId")) {
|
||||||
if(app_id_str == nullptr) {
|
app_id = std::stoi(*app_id_str);
|
||||||
LOG_WARN("No SteamAppId is set in current environment");
|
LOG_DEBUG("Found AppID from environment: {}", app_id);
|
||||||
|
|
||||||
|
return app_id;
|
||||||
|
}
|
||||||
|
} catch(std::exception&) {
|
||||||
|
LOG_WARN("No SteamAppId in environment. Falling back to ISteamUtils::GetAppID.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Then try to read steam_appid.txt here. SteamAppId env var is not available when it's present.
|
||||||
|
|
||||||
|
try {
|
||||||
|
DECLARE_ARGS();
|
||||||
|
|
||||||
|
THIS = CreateInterface("SteamClient007", nullptr);
|
||||||
|
if(!THIS) {
|
||||||
|
LOG_ERROR("Failed to create SteamClient interface");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static auto app_id = std::stoi(app_id_str);
|
THIS = ISteamClient_GetISteamGenericInterface(ARGS(1, 1, "SteamUtils002"));
|
||||||
|
if(!THIS) {
|
||||||
|
LOG_ERROR("Failed to get SteamUtils interface");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
app_id = ISteamUtils_GetAppID(ARGS());
|
||||||
|
if(!app_id) {
|
||||||
|
LOG_ERROR("ISteamUtils::GetAppID returned 0");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG_DEBUG("Found AppID from ISteamUtils: {}", app_id);
|
||||||
return app_id;
|
return app_id;
|
||||||
} catch(const std::exception& e) {
|
} catch(const std::exception& e) {
|
||||||
LOG_ERROR("Failed to get app id: {}", e.what());
|
LOG_ERROR("Failed to get app id: {}", e.what());
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ constexpr auto STEAM_APPS = "STEAMAPPS_INTERFACE_VERSION";
|
|||||||
constexpr auto STEAM_CLIENT = "SteamClient";
|
constexpr auto STEAM_CLIENT = "SteamClient";
|
||||||
constexpr auto STEAM_HTTP = "STEAMHTTP_INTERFACE_VERSION";
|
constexpr auto STEAM_HTTP = "STEAMHTTP_INTERFACE_VERSION";
|
||||||
constexpr auto STEAM_USER = "SteamUser";
|
constexpr auto STEAM_USER = "SteamUser";
|
||||||
|
constexpr auto STEAM_UTILS = "SteamUtils";
|
||||||
constexpr auto STEAM_INVENTORY = "STEAMINVENTORY_INTERFACE_V";
|
constexpr auto STEAM_INVENTORY = "STEAMINVENTORY_INTERFACE_V";
|
||||||
constexpr auto STEAM_GAME_SERVER = "SteamGameServer";
|
constexpr auto STEAM_GAME_SERVER = "SteamGameServer";
|
||||||
|
|
||||||
|
|||||||
@@ -4,12 +4,12 @@
|
|||||||
|
|
||||||
#include <koalabox/hook.hpp>
|
#include <koalabox/hook.hpp>
|
||||||
#include <koalabox/logger.hpp>
|
#include <koalabox/logger.hpp>
|
||||||
|
#include "koalabox/lib.hpp"
|
||||||
|
|
||||||
|
#include "smoke_api/steamclient/steamclient.hpp"
|
||||||
|
|
||||||
#include "steam_api/steam_interfaces.hpp"
|
#include "steam_api/steam_interfaces.hpp"
|
||||||
|
|
||||||
#include "koalabox/lib.hpp"
|
|
||||||
#include "smoke_api/smoke_api.hpp"
|
#include "smoke_api/smoke_api.hpp"
|
||||||
#include "smoke_api/steamclient/steamclient.hpp"
|
|
||||||
#include "virtuals/steam_api_virtuals.hpp"
|
#include "virtuals/steam_api_virtuals.hpp"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@@ -104,6 +104,15 @@ namespace {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
STEAM_UTILS,
|
||||||
|
interface_data_t{
|
||||||
|
.fallback_version = "SteamUtils009",
|
||||||
|
.entry_map = {
|
||||||
|
ENTRY(ISteamUtils, GetAppID),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -210,7 +219,9 @@ namespace steam_interfaces {
|
|||||||
const auto prefixes = std::views::keys(virtual_hook_map) | std::ranges::to<std::set>();
|
const auto prefixes = std::views::keys(virtual_hook_map) | std::ranges::to<std::set>();
|
||||||
|
|
||||||
const auto CreateInterface$ = KB_MOD_GET_FUNC(steamclient_handle, CreateInterface);
|
const auto CreateInterface$ = KB_MOD_GET_FUNC(steamclient_handle, CreateInterface);
|
||||||
const auto* const THIS = CreateInterface$(steam_client_interface_version.c_str(), nullptr);
|
|
||||||
|
DECLARE_ARGS();
|
||||||
|
THIS = CreateInterface$(steam_client_interface_version.c_str(), nullptr);
|
||||||
hook_virtuals(THIS, steam_client_interface_version);
|
hook_virtuals(THIS, steam_client_interface_version);
|
||||||
|
|
||||||
const auto interface_lookup = read_interface_lookup();
|
const auto interface_lookup = read_interface_lookup();
|
||||||
@@ -234,7 +245,6 @@ namespace steam_interfaces {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
DECLARE_EDX();
|
|
||||||
const auto* const interface_ptr = ISteamClient_GetISteamGenericInterface(
|
const auto* const interface_ptr = ISteamClient_GetISteamGenericInterface(
|
||||||
ARGS(steam_user, steam_pipe, interface_version.c_str())
|
ARGS(steam_user, steam_pipe, interface_version.c_str())
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "smoke_api/types.hpp"
|
#include <string>
|
||||||
|
|
||||||
namespace steam_interfaces {
|
namespace steam_interfaces {
|
||||||
void hook_virtuals(const void* interface_ptr, const std::string& version_string);
|
void hook_virtuals(const void* interface_ptr, const std::string& version_string);
|
||||||
|
|||||||
9
src/steam_api/virtuals/isteamutils.cpp
Normal file
9
src/steam_api/virtuals/isteamutils.cpp
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
#include <koalabox/logger.hpp>
|
||||||
|
|
||||||
|
#include "smoke_api/smoke_api.hpp"
|
||||||
|
#include "smoke_api/interfaces/steam_user.hpp"
|
||||||
|
#include "steam_api/virtuals/steam_api_virtuals.hpp"
|
||||||
|
|
||||||
|
VIRTUAL(AppId_t) ISteamUtils_GetAppID(PARAMS()) noexcept {
|
||||||
|
SWAPPED_CALL(THIS, ISteamUtils_GetAppID, ARGS());
|
||||||
|
}
|
||||||
@@ -11,21 +11,11 @@ VIRTUAL(bool) ISteamApps_BGetDLCDataByIndex(PARAMS(int, AppId_t*, bool*, char*,
|
|||||||
// ISteamClient
|
// ISteamClient
|
||||||
VIRTUAL(void*) ISteamClient_GetISteamApps(PARAMS(HSteamUser, HSteamPipe, const char*)) noexcept;
|
VIRTUAL(void*) ISteamClient_GetISteamApps(PARAMS(HSteamUser, HSteamPipe, const char*)) noexcept;
|
||||||
VIRTUAL(void*) ISteamClient_GetISteamUser(PARAMS(HSteamUser, HSteamPipe, const char*)) noexcept;
|
VIRTUAL(void*) ISteamClient_GetISteamUser(PARAMS(HSteamUser, HSteamPipe, const char*)) noexcept;
|
||||||
VIRTUAL(void*) ISteamClient_GetISteamGenericInterface(
|
VIRTUAL(void*) ISteamClient_GetISteamGenericInterface(PARAMS(HSteamUser, HSteamPipe, const char*)) noexcept;
|
||||||
PARAMS(HSteamUser, HSteamPipe, const char*)
|
VIRTUAL(void*) ISteamClient_GetISteamInventory(PARAMS(HSteamUser, HSteamPipe, const char*)) noexcept;
|
||||||
|
|
||||||
|
|
||||||
) noexcept;
|
|
||||||
VIRTUAL(void*) ISteamClient_GetISteamInventory(
|
|
||||||
PARAMS(HSteamUser, HSteamPipe, const char*)
|
|
||||||
|
|
||||||
|
|
||||||
) noexcept;
|
|
||||||
|
|
||||||
// ISteamHTTP
|
// ISteamHTTP
|
||||||
VIRTUAL(bool) ISteamHTTP_GetHTTPResponseBodyData(
|
VIRTUAL(bool) ISteamHTTP_GetHTTPResponseBodyData(PARAMS(HTTPRequestHandle, const uint8_t*, uint32_t)) noexcept;
|
||||||
PARAMS(HTTPRequestHandle, const uint8_t*, uint32_t)
|
|
||||||
) noexcept;
|
|
||||||
VIRTUAL(bool) ISteamHTTP_GetHTTPStreamingResponseBodyData(
|
VIRTUAL(bool) ISteamHTTP_GetHTTPStreamingResponseBodyData(
|
||||||
PARAMS(HTTPRequestHandle, uint32_t, const uint8_t*, uint32_t)
|
PARAMS(HTTPRequestHandle, uint32_t, const uint8_t*, uint32_t)
|
||||||
) noexcept;
|
) noexcept;
|
||||||
@@ -38,7 +28,6 @@ VIRTUAL(EResult) ISteamInventory_GetResultStatus(PARAMS(SteamInventoryResult_t))
|
|||||||
VIRTUAL(bool) ISteamInventory_GetResultItems(
|
VIRTUAL(bool) ISteamInventory_GetResultItems(
|
||||||
PARAMS(SteamInventoryResult_t, SteamItemDetails_t*, uint32_t*) // @formatter:off
|
PARAMS(SteamInventoryResult_t, SteamItemDetails_t*, uint32_t*) // @formatter:off
|
||||||
) noexcept; // @formatter:on
|
) noexcept; // @formatter:on
|
||||||
|
|
||||||
VIRTUAL(bool) ISteamInventory_GetResultItemProperty(
|
VIRTUAL(bool) ISteamInventory_GetResultItemProperty(
|
||||||
PARAMS(SteamInventoryResult_t, uint32_t, const char*, char*, uint32_t*) // @formatter:off
|
PARAMS(SteamInventoryResult_t, uint32_t, const char*, char*, uint32_t*) // @formatter:off
|
||||||
) noexcept; // @formatter:on
|
) noexcept; // @formatter:on
|
||||||
@@ -46,20 +35,15 @@ VIRTUAL(bool) ISteamInventory_GetAllItems(PARAMS(SteamInventoryResult_t*)) noexc
|
|||||||
VIRTUAL(bool) ISteamInventory_GetItemsByID(
|
VIRTUAL(bool) ISteamInventory_GetItemsByID(
|
||||||
PARAMS(SteamInventoryResult_t*, const SteamItemInstanceID_t*, uint32_t)
|
PARAMS(SteamInventoryResult_t*, const SteamItemInstanceID_t*, uint32_t)
|
||||||
) noexcept;
|
) noexcept;
|
||||||
VIRTUAL(bool) ISteamInventory_SerializeResult(
|
VIRTUAL(bool) ISteamInventory_SerializeResult(PARAMS(SteamInventoryResult_t, void*, uint32_t*)) noexcept;
|
||||||
PARAMS(SteamInventoryResult_t, void*, uint32_t*)
|
|
||||||
|
|
||||||
|
|
||||||
) noexcept;
|
|
||||||
VIRTUAL(bool) ISteamInventory_GetItemDefinitionIDs(PARAMS(SteamItemDef_t*, uint32_t*)) noexcept;
|
VIRTUAL(bool) ISteamInventory_GetItemDefinitionIDs(PARAMS(SteamItemDef_t*, uint32_t*)) noexcept;
|
||||||
VIRTUAL(bool) ISteamInventory_CheckResultSteamID(PARAMS(SteamInventoryResult_t, CSteamID)) noexcept;
|
VIRTUAL(bool) ISteamInventory_CheckResultSteamID(PARAMS(SteamInventoryResult_t, CSteamID)) noexcept;
|
||||||
|
|
||||||
// ISteamUser
|
// ISteamUser
|
||||||
VIRTUAL(EUserHasLicenseForAppResult) ISteamUser_UserHasLicenseForApp(
|
VIRTUAL(EUserHasLicenseForAppResult) ISteamUser_UserHasLicenseForApp(PARAMS(CSteamID, AppId_t)) noexcept;
|
||||||
PARAMS(CSteamID, AppId_t)
|
|
||||||
) noexcept;
|
// ISteamUtils
|
||||||
|
VIRTUAL(AppId_t) ISteamUtils_GetAppID(PARAMS()) noexcept;
|
||||||
|
|
||||||
// ISteamGameServer
|
// ISteamGameServer
|
||||||
VIRTUAL(EUserHasLicenseForAppResult) ISteamGameServer_UserHasLicenseForApp(
|
VIRTUAL(EUserHasLicenseForAppResult) ISteamGameServer_UserHasLicenseForApp(PARAMS(CSteamID, AppId_t)) noexcept;
|
||||||
PARAMS(CSteamID, AppId_t)
|
|
||||||
) noexcept;
|
|
||||||
|
|||||||
@@ -46,12 +46,12 @@
|
|||||||
#define PARAMS(...) const void* RCX __VA_OPT__(,) __VA_ARGS__
|
#define PARAMS(...) const void* RCX __VA_OPT__(,) __VA_ARGS__
|
||||||
#define ARGS(...) RCX __VA_OPT__(,) __VA_ARGS__
|
#define ARGS(...) RCX __VA_OPT__(,) __VA_ARGS__
|
||||||
#define THIS RCX
|
#define THIS RCX
|
||||||
#define DECLARE_EDX()
|
#define DECLARE_ARGS() const void* RCX = nullptr;
|
||||||
#else
|
#else
|
||||||
#define PARAMS(...) const void* ECX, const void* EDX __VA_OPT__(,) __VA_ARGS__
|
#define PARAMS(...) const void* ECX, const void* EDX __VA_OPT__(,) __VA_ARGS__
|
||||||
#define ARGS(...) ECX, EDX __VA_OPT__(,) __VA_ARGS__
|
#define ARGS(...) ECX, EDX __VA_OPT__(,) __VA_ARGS__
|
||||||
#define THIS ECX
|
#define THIS ECX
|
||||||
#define DECLARE_EDX() const void* EDX = nullptr;
|
#define DECLARE_ARGS() const void* ECX = nullptr; const void* EDX = nullptr;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using AppId_t = uint32_t;
|
using AppId_t = uint32_t;
|
||||||
@@ -112,8 +112,9 @@ public:
|
|||||||
|
|
||||||
explicit DLC() = default;
|
explicit DLC() = default;
|
||||||
|
|
||||||
explicit DLC(std::string appid, std::string name) : appid{std::move(appid)},
|
explicit DLC(std::string appid, std::string name)
|
||||||
name{std::move(name)} {}
|
: appid{std::move(appid)},
|
||||||
|
name{std::move(name)} {}
|
||||||
|
|
||||||
[[nodiscard]] std::string get_id_str() const {
|
[[nodiscard]] std::string get_id_str() const {
|
||||||
return appid;
|
return appid;
|
||||||
|
|||||||
Reference in New Issue
Block a user