mirror of
https://github.com/acidicoala/SmokeAPI.git
synced 2026-01-28 23:42:52 -05:00
Moved get_app_id()
This commit is contained in:
@@ -49,8 +49,8 @@ set(SMOKE_API_SOURCES
|
|||||||
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
|
||||||
src/steam_api/steam_interface.cpp
|
src/steam_api/steam_interfaces.cpp
|
||||||
src/steam_api/steam_interface.hpp
|
src/steam_api/steam_interfaces.hpp
|
||||||
src/steamclient/steamclient.cpp
|
src/steamclient/steamclient.cpp
|
||||||
src/main.cpp
|
src/main.cpp
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
#include <koalabox/logger.hpp>
|
#include <koalabox/logger.hpp>
|
||||||
#include <koalabox/path.hpp>
|
#include <koalabox/path.hpp>
|
||||||
#include <koalabox/paths.hpp>
|
#include <koalabox/paths.hpp>
|
||||||
#include <koalabox/str.hpp>
|
|
||||||
#include <koalabox/util.hpp>
|
#include <koalabox/util.hpp>
|
||||||
#include <koalabox/win.hpp>
|
#include <koalabox/win.hpp>
|
||||||
|
|
||||||
@@ -115,4 +114,15 @@ namespace smoke_api {
|
|||||||
|
|
||||||
kb::logger::shutdown();
|
kb::logger::shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AppId_t get_app_id() {
|
||||||
|
try {
|
||||||
|
const auto app_id_str = kb::win::get_env_var("SteamAppId");
|
||||||
|
static auto app_id = std::stoi(app_id_str);
|
||||||
|
return app_id;
|
||||||
|
} catch(const std::exception& e) {
|
||||||
|
LOG_ERROR("Failed to get app id: {}", e.what());
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <koalabox/win.hpp>
|
#include "smoke_api/types.hpp"
|
||||||
|
|
||||||
constexpr auto STEAM_APPS = "STEAMAPPS_INTERFACE_VERSION";
|
constexpr auto STEAM_APPS = "STEAMAPPS_INTERFACE_VERSION";
|
||||||
constexpr auto STEAM_CLIENT = "SteamClient";
|
constexpr auto STEAM_CLIENT = "SteamClient";
|
||||||
@@ -15,10 +15,10 @@ constexpr auto STEAM_GAME_SERVER = "SteamGameServer";
|
|||||||
|
|
||||||
namespace smoke_api {
|
namespace smoke_api {
|
||||||
extern HMODULE steamapi_module;
|
extern HMODULE steamapi_module;
|
||||||
|
|
||||||
extern bool hook_mode;
|
extern bool hook_mode;
|
||||||
|
|
||||||
void init(HMODULE module_handle);
|
void init(HMODULE module_handle);
|
||||||
|
|
||||||
void shutdown();
|
void shutdown();
|
||||||
|
|
||||||
|
AppId_t get_app_id();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
#include <koalabox/logger.hpp>
|
#include <koalabox/logger.hpp>
|
||||||
|
|
||||||
#include "steam_api/steam_interface.hpp"
|
#include "steam_api/steam_interfaces.hpp"
|
||||||
#include "steam_client.hpp"
|
#include "steam_client.hpp"
|
||||||
|
|
||||||
namespace steam_client {
|
namespace steam_client {
|
||||||
@@ -14,7 +14,7 @@ namespace steam_client {
|
|||||||
|
|
||||||
LOG_DEBUG("{} -> '{}' @ {}", function_name, interface_version, interface);
|
LOG_DEBUG("{} -> '{}' @ {}", function_name, interface_version, interface);
|
||||||
|
|
||||||
steam_interface::hook_virtuals(interface, interface_version);
|
steam_interfaces::hook_virtuals(interface, interface_version);
|
||||||
|
|
||||||
return interface;
|
return interface;
|
||||||
} catch(const std::exception& e) {
|
} catch(const std::exception& e) {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
#include <koalabox/logger.hpp>
|
#include <koalabox/logger.hpp>
|
||||||
#include <koalabox/win.hpp>
|
#include <koalabox/win.hpp>
|
||||||
|
|
||||||
#include "steam_api/steam_interface.hpp"
|
#include "steam_api/steam_interfaces.hpp"
|
||||||
#include "smoke_api/smoke_api.hpp"
|
#include "smoke_api/smoke_api.hpp"
|
||||||
#include "virtuals/steam_api_virtuals.hpp"
|
#include "virtuals/steam_api_virtuals.hpp"
|
||||||
|
|
||||||
@@ -135,24 +135,9 @@ namespace {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace steam_interface {
|
namespace steam_interfaces {
|
||||||
namespace kb = koalabox;
|
namespace kb = koalabox;
|
||||||
|
|
||||||
AppId_t get_app_id_or_throw() {
|
|
||||||
const auto app_id_str = kb::win::get_env_var("SteamAppId");
|
|
||||||
return std::stoi(app_id_str);
|
|
||||||
}
|
|
||||||
|
|
||||||
AppId_t get_app_id() {
|
|
||||||
try {
|
|
||||||
static const auto app_id = get_app_id_or_throw();
|
|
||||||
return app_id;
|
|
||||||
} catch(const std::exception& e) {
|
|
||||||
LOG_ERROR("Failed to get app id: {}", e.what());
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param interface_ptr Pointer to the interface
|
* @param interface_ptr Pointer to the interface
|
||||||
* @param version_string Example: 'SteamClient020'
|
* @param version_string Example: 'SteamClient020'
|
||||||
@@ -2,9 +2,8 @@
|
|||||||
|
|
||||||
#include "smoke_api/types.hpp"
|
#include "smoke_api/types.hpp"
|
||||||
|
|
||||||
namespace steam_interface {
|
namespace steam_interfaces {
|
||||||
AppId_t get_app_id_or_throw();
|
|
||||||
AppId_t get_app_id();
|
|
||||||
|
|
||||||
void hook_virtuals(void* interface_ptr, const std::string& version_string);
|
void hook_virtuals(void* interface_ptr, const std::string& version_string);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,13 +1,13 @@
|
|||||||
#include <koalabox/logger.hpp>
|
#include <koalabox/logger.hpp>
|
||||||
|
|
||||||
|
#include "smoke_api/smoke_api.hpp"
|
||||||
#include "smoke_api/interfaces/steam_apps.hpp"
|
#include "smoke_api/interfaces/steam_apps.hpp"
|
||||||
#include "steam_api/steam_interface.hpp"
|
|
||||||
#include "steam_api/virtuals/steam_api_virtuals.hpp"
|
#include "steam_api/virtuals/steam_api_virtuals.hpp"
|
||||||
|
|
||||||
VIRTUAL(bool) ISteamApps_BIsSubscribedApp(PARAMS(const AppId_t dlc_id)) noexcept {
|
VIRTUAL(bool) ISteamApps_BIsSubscribedApp(PARAMS(const AppId_t dlc_id)) noexcept {
|
||||||
return smoke_api::steam_apps::IsDlcUnlocked(
|
return smoke_api::steam_apps::IsDlcUnlocked(
|
||||||
__func__,
|
__func__,
|
||||||
steam_interface::get_app_id(),
|
smoke_api::get_app_id(),
|
||||||
dlc_id,
|
dlc_id,
|
||||||
SWAPPED_CALL_CLOSURE(ISteamApps_BIsSubscribedApp, ARGS(dlc_id))
|
SWAPPED_CALL_CLOSURE(ISteamApps_BIsSubscribedApp, ARGS(dlc_id))
|
||||||
);
|
);
|
||||||
@@ -16,7 +16,7 @@ VIRTUAL(bool) ISteamApps_BIsSubscribedApp(PARAMS(const AppId_t dlc_id)) noexcept
|
|||||||
VIRTUAL(bool) ISteamApps_BIsDlcInstalled(PARAMS(const AppId_t dlc_id)) noexcept {
|
VIRTUAL(bool) ISteamApps_BIsDlcInstalled(PARAMS(const AppId_t dlc_id)) noexcept {
|
||||||
return smoke_api::steam_apps::IsDlcUnlocked(
|
return smoke_api::steam_apps::IsDlcUnlocked(
|
||||||
__func__,
|
__func__,
|
||||||
steam_interface::get_app_id(),
|
smoke_api::get_app_id(),
|
||||||
dlc_id,
|
dlc_id,
|
||||||
SWAPPED_CALL_CLOSURE(ISteamApps_BIsDlcInstalled, ARGS(dlc_id))
|
SWAPPED_CALL_CLOSURE(ISteamApps_BIsDlcInstalled, ARGS(dlc_id))
|
||||||
);
|
);
|
||||||
@@ -25,7 +25,7 @@ VIRTUAL(bool) ISteamApps_BIsDlcInstalled(PARAMS(const AppId_t dlc_id)) noexcept
|
|||||||
VIRTUAL(int) ISteamApps_GetDLCCount(PARAMS()) noexcept {
|
VIRTUAL(int) ISteamApps_GetDLCCount(PARAMS()) noexcept {
|
||||||
return smoke_api::steam_apps::GetDLCCount(
|
return smoke_api::steam_apps::GetDLCCount(
|
||||||
__func__,
|
__func__,
|
||||||
steam_interface::get_app_id(),
|
smoke_api::get_app_id(),
|
||||||
SWAPPED_CALL_CLOSURE(ISteamApps_GetDLCCount, ARGS())
|
SWAPPED_CALL_CLOSURE(ISteamApps_GetDLCCount, ARGS())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -41,7 +41,7 @@ VIRTUAL(bool) ISteamApps_BGetDLCDataByIndex(
|
|||||||
) noexcept {
|
) noexcept {
|
||||||
return smoke_api::steam_apps::GetDLCDataByIndex(
|
return smoke_api::steam_apps::GetDLCDataByIndex(
|
||||||
__func__,
|
__func__,
|
||||||
steam_interface::get_app_id(),
|
smoke_api::get_app_id(),
|
||||||
iDLC,
|
iDLC,
|
||||||
p_dlc_id,
|
p_dlc_id,
|
||||||
pbAvailable,
|
pbAvailable,
|
||||||
@@ -52,8 +52,8 @@ VIRTUAL(bool) ISteamApps_BGetDLCDataByIndex(
|
|||||||
ARGS(iDLC, p_dlc_id, pbAvailable, pchName, cchNameBufferSize)
|
ARGS(iDLC, p_dlc_id, pbAvailable, pchName, cchNameBufferSize)
|
||||||
),
|
),
|
||||||
SWAPPED_CALL_CLOSURE(
|
SWAPPED_CALL_CLOSURE(
|
||||||
ISteamApps_BIsSubscribedApp,
|
ISteamApps_BIsSubscribedApp,
|
||||||
ARGS(*p_dlc_id)
|
ARGS(*p_dlc_id)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include <koalabox/logger.hpp>
|
#include <koalabox/logger.hpp>
|
||||||
|
|
||||||
|
#include "smoke_api/smoke_api.hpp"
|
||||||
#include "smoke_api/interfaces/steam_user.hpp"
|
#include "smoke_api/interfaces/steam_user.hpp"
|
||||||
#include "steam_api/steam_interface.hpp"
|
|
||||||
#include "steam_api/virtuals/steam_api_virtuals.hpp"
|
#include "steam_api/virtuals/steam_api_virtuals.hpp"
|
||||||
|
|
||||||
VIRTUAL(EUserHasLicenseForAppResult) ISteamGameServer_UserHasLicenseForApp(
|
VIRTUAL(EUserHasLicenseForAppResult) ISteamGameServer_UserHasLicenseForApp(
|
||||||
@@ -9,7 +9,7 @@ VIRTUAL(EUserHasLicenseForAppResult) ISteamGameServer_UserHasLicenseForApp(
|
|||||||
) noexcept {
|
) noexcept {
|
||||||
return smoke_api::steam_user::UserHasLicenseForApp(
|
return smoke_api::steam_user::UserHasLicenseForApp(
|
||||||
__func__,
|
__func__,
|
||||||
steam_interface::get_app_id(),
|
smoke_api::get_app_id(),
|
||||||
dlc_id,
|
dlc_id,
|
||||||
SWAPPED_CALL_CLOSURE(ISteamGameServer_UserHasLicenseForApp, ARGS(steamID, dlc_id))
|
SWAPPED_CALL_CLOSURE(ISteamGameServer_UserHasLicenseForApp, ARGS(steamID, dlc_id))
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
#include <koalabox/logger.hpp>
|
#include <koalabox/logger.hpp>
|
||||||
|
|
||||||
#include "smoke_api/interfaces/steam_http.hpp"
|
#include "smoke_api/interfaces/steam_http.hpp"
|
||||||
#include "steam_api/steam_interface.hpp"
|
|
||||||
#include "steam_api/virtuals/steam_api_virtuals.hpp"
|
#include "steam_api/virtuals/steam_api_virtuals.hpp"
|
||||||
|
|
||||||
VIRTUAL(bool) ISteamHTTP_GetHTTPResponseBodyData(
|
VIRTUAL(bool) ISteamHTTP_GetHTTPResponseBodyData(
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include <koalabox/logger.hpp>
|
#include <koalabox/logger.hpp>
|
||||||
|
|
||||||
|
#include "smoke_api/smoke_api.hpp"
|
||||||
#include "smoke_api/interfaces/steam_user.hpp"
|
#include "smoke_api/interfaces/steam_user.hpp"
|
||||||
#include "steam_api/steam_interface.hpp"
|
|
||||||
#include "steam_api/virtuals/steam_api_virtuals.hpp"
|
#include "steam_api/virtuals/steam_api_virtuals.hpp"
|
||||||
|
|
||||||
VIRTUAL(EUserHasLicenseForAppResult) ISteamUser_UserHasLicenseForApp(
|
VIRTUAL(EUserHasLicenseForAppResult) ISteamUser_UserHasLicenseForApp(
|
||||||
@@ -9,7 +9,7 @@ VIRTUAL(EUserHasLicenseForAppResult) ISteamUser_UserHasLicenseForApp(
|
|||||||
) noexcept {
|
) noexcept {
|
||||||
return smoke_api::steam_user::UserHasLicenseForApp(
|
return smoke_api::steam_user::UserHasLicenseForApp(
|
||||||
__func__,
|
__func__,
|
||||||
steam_interface::get_app_id(),
|
smoke_api::get_app_id(),
|
||||||
dlc_id,
|
dlc_id,
|
||||||
SWAPPED_CALL_CLOSURE(ISteamUser_UserHasLicenseForApp, ARGS(steamID, dlc_id))
|
SWAPPED_CALL_CLOSURE(ISteamUser_UserHasLicenseForApp, ARGS(steamID, dlc_id))
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user