mirror of
https://github.com/acidicoala/SmokeAPI.git
synced 2026-01-25 05:52:51 -05:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d3a11186d0 | ||
|
|
ec10445710 | ||
|
|
53d28ee65d | ||
|
|
5b76d155a8 | ||
|
|
be9fa39508 | ||
|
|
5d1abc6498 |
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@@ -4,7 +4,7 @@ on: push
|
|||||||
jobs:
|
jobs:
|
||||||
ci:
|
ci:
|
||||||
name: CI
|
name: CI
|
||||||
uses: acidicoala/KoalaBox/.github/workflows/build-and-package.yml@a1a8661947cc3260ed217ec75fb8cf15825cdf6e
|
uses: acidicoala/KoalaBox/.github/workflows/build-and-package.yml@d9b0d1a00beb065a9a931a60ef615ce8d1fc7164
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
with:
|
with:
|
||||||
|
|||||||
10
.idea/cmake.xml
generated
10
.idea/cmake.xml
generated
@@ -1,10 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="CMakeSharedSettings">
|
|
||||||
<configurations>
|
|
||||||
<configuration PROFILE_NAME="Debug [32]" ENABLED="true" GENERATION_DIR="build/32" CONFIG_NAME="Debug" TOOLCHAIN_NAME="Visual Studio 2022 [x86]" GENERATION_OPTIONS="-G "Visual Studio 17 2022" -A Win32" />
|
|
||||||
<configuration PROFILE_NAME="Debug [64]" ENABLED="true" GENERATION_DIR="build/64" CONFIG_NAME="Debug" TOOLCHAIN_NAME="Visual Studio 2022 [amd64]" GENERATION_OPTIONS="-G "Visual Studio 17 2022" -A x64" />
|
|
||||||
<configuration PROFILE_NAME="Relase [64]" ENABLED="false" GENERATION_DIR="build/64/release" CONFIG_NAME="Release" TOOLCHAIN_NAME="Visual Studio 2022 [amd64]" GENERATION_OPTIONS="-G "Visual Studio 17 2022" -A x64" />
|
|
||||||
</configurations>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
cmake_minimum_required(VERSION 3.22)
|
cmake_minimum_required(VERSION 3.22)
|
||||||
|
|
||||||
project(SmokeAPI VERSION 1.0.0)
|
project(SmokeAPI VERSION 1.0.3)
|
||||||
|
|
||||||
include(KoalaBox/cmake/KoalaBox.cmake)
|
include(KoalaBox/cmake/KoalaBox.cmake)
|
||||||
|
|
||||||
@@ -53,11 +53,22 @@ set(
|
|||||||
src/steam_functions/steam_functions.hpp
|
src/steam_functions/steam_functions.hpp
|
||||||
src/steam_types/steam_types.hpp
|
src/steam_types/steam_types.hpp
|
||||||
src/steamclient_exports/steamclient.cpp
|
src/steamclient_exports/steamclient.cpp
|
||||||
src/vstdlib/vstdlib.cpp
|
|
||||||
src/main.cpp
|
src/main.cpp
|
||||||
${GENERATED_LINKER_EXPORTS}
|
${GENERATED_LINKER_EXPORTS}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||||
|
set(
|
||||||
|
SMOKE_API_SOURCES ${SMOKE_API_SOURCES}
|
||||||
|
src/koalageddon/vstdlib.cpp
|
||||||
|
src/koalageddon/steamclient.cpp
|
||||||
|
src/steamclient_virtuals/client_app_manager.cpp
|
||||||
|
src/steamclient_virtuals/client_apps.cpp
|
||||||
|
src/steamclient_virtuals/client_inventory.cpp
|
||||||
|
src/steamclient_virtuals/client_user.cpp
|
||||||
|
)
|
||||||
|
endif ()
|
||||||
|
|
||||||
add_library(SmokeAPI SHARED ${SMOKE_API_SOURCES} ${VERSION_RESOURCE})
|
add_library(SmokeAPI SHARED ${SMOKE_API_SOURCES} ${VERSION_RESOURCE})
|
||||||
|
|
||||||
configure_output_name(${ORIGINAL_DLL})
|
configure_output_name(${ORIGINAL_DLL})
|
||||||
|
|||||||
2
KoalaBox
2
KoalaBox
Submodule KoalaBox updated: a1a8661947...d9b0d1a00b
54
src/koalageddon/steamclient.cpp
Normal file
54
src/koalageddon/steamclient.cpp
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
#include <smoke_api/smoke_api.hpp>
|
||||||
|
#include <steam_functions/steam_functions.hpp>
|
||||||
|
|
||||||
|
#include <koalabox/hook.hpp>
|
||||||
|
|
||||||
|
using namespace smoke_api;
|
||||||
|
|
||||||
|
|
||||||
|
DLL_EXPORT(void) Log_Interface(const char* interface_name, const char* function_name) {
|
||||||
|
try {
|
||||||
|
void**** parent_ebp;
|
||||||
|
|
||||||
|
__asm mov parent_ebp, ebp
|
||||||
|
|
||||||
|
auto* interface_address = (*parent_ebp)[2];
|
||||||
|
|
||||||
|
static Set<String> hooked_functions;
|
||||||
|
|
||||||
|
auto hook_function = [&](const auto hook_function, const String& name, const int ordinal) {
|
||||||
|
if (hooked_functions.contains(name)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
hook::swap_virtual_func_or_throw(interface_address, name, ordinal, (FunctionAddress) (hook_function));
|
||||||
|
|
||||||
|
hooked_functions.insert(name);
|
||||||
|
};
|
||||||
|
|
||||||
|
const auto compound_name = interface_name + String("::") + function_name;
|
||||||
|
|
||||||
|
#define HOOK(FUNC, ORDINAL) hook_function(FUNC, #FUNC, ORDINAL);
|
||||||
|
|
||||||
|
if (util::strings_are_equal(interface_name, "IClientAppManager")) {
|
||||||
|
HOOK(IClientAppManager_IsAppDlcInstalled, 8)
|
||||||
|
} else if (util::strings_are_equal(interface_name, "IClientApps")) {
|
||||||
|
HOOK(IClientApps_GetDLCCount, 8)
|
||||||
|
HOOK(IClientApps_BGetDLCDataByIndex, 9)
|
||||||
|
} else if (util::strings_are_equal(interface_name, "IClientInventory")) {
|
||||||
|
HOOK(IClientInventory_GetResultStatus, 0)
|
||||||
|
HOOK(IClientInventory_GetResultItems, 2)
|
||||||
|
HOOK(IClientInventory_GetResultItemProperty, 3)
|
||||||
|
HOOK(IClientInventory_CheckResultSteamID, 5)
|
||||||
|
HOOK(IClientInventory_GetAllItems, 8)
|
||||||
|
HOOK(IClientInventory_GetItemsByID, 9)
|
||||||
|
HOOK(IClientInventory_SerializeResult, 6)
|
||||||
|
HOOK(IClientInventory_GetItemDefinitionIDs, 19)
|
||||||
|
}
|
||||||
|
|
||||||
|
GET_ORIGINAL_FUNCTION(Log_Interface)
|
||||||
|
Log_Interface_o(interface_name, function_name);
|
||||||
|
} catch (const Exception& ex) {
|
||||||
|
logger->error("{} -> Error: {}", __func__, ex.what());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,13 +2,17 @@
|
|||||||
#include <steam_functions/steam_functions.hpp>
|
#include <steam_functions/steam_functions.hpp>
|
||||||
#include <build_config.h>
|
#include <build_config.h>
|
||||||
|
|
||||||
#include <koalabox/loader.hpp>
|
|
||||||
#include <koalabox/config_parser.hpp>
|
#include <koalabox/config_parser.hpp>
|
||||||
#include <koalabox/file_logger.hpp>
|
|
||||||
#include <koalabox/win_util.hpp>
|
|
||||||
#include <koalabox/hook.hpp>
|
|
||||||
#include <koalabox/dll_monitor.hpp>
|
#include <koalabox/dll_monitor.hpp>
|
||||||
|
#include <koalabox/file_logger.hpp>
|
||||||
|
#include <koalabox/hook.hpp>
|
||||||
|
#include <koalabox/loader.hpp>
|
||||||
|
#include <koalabox/win_util.hpp>
|
||||||
|
#ifndef _WIN64
|
||||||
|
#include <koalabox/patcher.hpp>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define DETOUR_EX(FUNC, ADDRESS) hook::detour_or_warn(ADDRESS, #FUNC, reinterpret_cast<FunctionAddress>(FUNC));
|
||||||
#define DETOUR(FUNC) hook::detour_or_warn(original_library, #FUNC, reinterpret_cast<FunctionAddress>(FUNC));
|
#define DETOUR(FUNC) hook::detour_or_warn(original_library, #FUNC, reinterpret_cast<FunctionAddress>(FUNC));
|
||||||
|
|
||||||
namespace smoke_api {
|
namespace smoke_api {
|
||||||
@@ -47,14 +51,29 @@ namespace smoke_api {
|
|||||||
if (is_hook_mode) {
|
if (is_hook_mode) {
|
||||||
hook::init(true);
|
hook::init(true);
|
||||||
|
|
||||||
if (util::strings_are_equal(exe_name, "steam.exe")) { // target vstdlib_s.dll
|
if (util::strings_are_equal(exe_name, "steam.exe")) {
|
||||||
|
#ifndef _WIN64
|
||||||
logger->info("🐨 Detected Koalageddon mode 💥");
|
logger->info("🐨 Detected Koalageddon mode 💥");
|
||||||
|
|
||||||
dll_monitor::init(VSTDLIB_DLL, [](const HMODULE& library) {
|
dll_monitor::init({VSTDLIB_DLL, STEAMCLIENT_DLL}, [](const HMODULE& library, const String& name) {
|
||||||
original_library = library;
|
original_library = library; // TODO: Is this necessary?
|
||||||
|
|
||||||
DETOUR(Coroutine_Create)
|
if (name == VSTDLIB_DLL) {
|
||||||
|
// Family Sharing functions
|
||||||
|
DETOUR(Coroutine_Create)
|
||||||
|
} else if (name == STEAMCLIENT_DLL) {
|
||||||
|
// Unlocking functions
|
||||||
|
// TODO: Un-hardcode the pattern
|
||||||
|
const String pattern("55 8B EC 8B ?? ?? ?? ?? ?? 81 EC ?? ?? ?? ?? 53 FF 15");
|
||||||
|
auto Log_Interface_address = (FunctionAddress) patcher::find_pattern_address(
|
||||||
|
win_util::get_module_info(library), "Log_Interface", pattern
|
||||||
|
);
|
||||||
|
if (Log_Interface_address) {
|
||||||
|
DETOUR_EX(Log_Interface, Log_Interface_address)
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
#endif
|
||||||
} else if (config.hook_steamclient) { // target steamclient(64).dll
|
} else if (config.hook_steamclient) { // target steamclient(64).dll
|
||||||
logger->info("🪝 Detected hook mode for SteamClient");
|
logger->info("🪝 Detected hook mode for SteamClient");
|
||||||
|
|
||||||
@@ -88,7 +107,6 @@ namespace smoke_api {
|
|||||||
DETOUR(SteamAPI_ISteamInventory_GetAllItems)
|
DETOUR(SteamAPI_ISteamInventory_GetAllItems)
|
||||||
DETOUR(SteamAPI_ISteamInventory_GetItemsByID)
|
DETOUR(SteamAPI_ISteamInventory_GetItemsByID)
|
||||||
DETOUR(SteamAPI_ISteamInventory_GetItemDefinitionIDs)
|
DETOUR(SteamAPI_ISteamInventory_GetItemDefinitionIDs)
|
||||||
DETOUR(SteamAPI_ISteamInventory_GetItemDefinitionProperty)
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -116,8 +134,8 @@ namespace smoke_api {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool should_unlock(uint32_t appId) {
|
bool should_unlock(uint32_t app_id) {
|
||||||
return config.unlock_all != config.override.contains(appId);
|
return config.unlock_all != config.override.contains(app_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,6 +58,6 @@ namespace smoke_api {
|
|||||||
|
|
||||||
void shutdown();
|
void shutdown();
|
||||||
|
|
||||||
bool should_unlock(uint32_t appId);
|
bool should_unlock(uint32_t app_id);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,15 +6,15 @@ using namespace smoke_api;
|
|||||||
// ISteamApps
|
// ISteamApps
|
||||||
|
|
||||||
DLL_EXPORT(bool) SteamAPI_ISteamApps_BIsSubscribedApp(ISteamApps*, AppId_t appID) {
|
DLL_EXPORT(bool) SteamAPI_ISteamApps_BIsSubscribedApp(ISteamApps*, AppId_t appID) {
|
||||||
return steam_apps::IsSubscribedApp(__func__, appID);
|
return steam_apps::IsDlcUnlocked(__func__, 0, appID);
|
||||||
}
|
}
|
||||||
|
|
||||||
DLL_EXPORT(bool) SteamAPI_ISteamApps_BIsDlcInstalled(ISteamApps*, AppId_t appID) {
|
DLL_EXPORT(bool) SteamAPI_ISteamApps_BIsDlcInstalled(ISteamApps*, AppId_t appID) {
|
||||||
return steam_apps::IsDlcInstalled(__func__, appID);
|
return steam_apps::IsDlcUnlocked(__func__, 0, appID);
|
||||||
}
|
}
|
||||||
|
|
||||||
DLL_EXPORT(int) SteamAPI_ISteamApps_GetDLCCount(ISteamApps* self) {
|
DLL_EXPORT(int) SteamAPI_ISteamApps_GetDLCCount(ISteamApps* self) {
|
||||||
return steam_apps::GetDLCCount(__func__, [&]() {
|
return steam_apps::GetDLCCount(__func__, 0, [&]() {
|
||||||
GET_ORIGINAL_FUNCTION(SteamAPI_ISteamApps_GetDLCCount)
|
GET_ORIGINAL_FUNCTION(SteamAPI_ISteamApps_GetDLCCount)
|
||||||
|
|
||||||
return SteamAPI_ISteamApps_GetDLCCount_o(self);
|
return SteamAPI_ISteamApps_GetDLCCount_o(self);
|
||||||
@@ -29,7 +29,7 @@ DLL_EXPORT(bool) SteamAPI_ISteamApps_BGetDLCDataByIndex(
|
|||||||
char* pchName,
|
char* pchName,
|
||||||
int cchNameBufferSize
|
int cchNameBufferSize
|
||||||
) {
|
) {
|
||||||
return steam_apps::GetDLCDataByIndex(__func__, iDLC, pAppID, pbAvailable, pchName, cchNameBufferSize, [&]() {
|
return steam_apps::GetDLCDataByIndex(__func__, 0, iDLC, pAppID, pbAvailable, pchName, cchNameBufferSize, [&]() {
|
||||||
GET_ORIGINAL_FUNCTION(SteamAPI_ISteamApps_BGetDLCDataByIndex)
|
GET_ORIGINAL_FUNCTION(SteamAPI_ISteamApps_BGetDLCDataByIndex)
|
||||||
|
|
||||||
return SteamAPI_ISteamApps_BGetDLCDataByIndex_o(
|
return SteamAPI_ISteamApps_BGetDLCDataByIndex_o(
|
||||||
@@ -107,11 +107,11 @@ DLL_EXPORT(bool) SteamAPI_ISteamInventory_GetResultItemProperty(
|
|||||||
uint32_t unItemIndex,
|
uint32_t unItemIndex,
|
||||||
const char* pchPropertyName,
|
const char* pchPropertyName,
|
||||||
char* pchValueBuffer,
|
char* pchValueBuffer,
|
||||||
const uint32_t* punValueBufferSizeOut
|
uint32_t* punValueBufferSizeOut
|
||||||
) {
|
) {
|
||||||
return steam_inventory::GetResultItemProperty(
|
return steam_inventory::GetResultItemProperty(
|
||||||
__func__, resultHandle, unItemIndex, pchPropertyName, pchValueBuffer, punValueBufferSizeOut, [&]() {
|
__func__, resultHandle, unItemIndex, pchPropertyName, pchValueBuffer, punValueBufferSizeOut, [&]() {
|
||||||
GET_ORIGINAL_VIRTUAL_FUNCTION(SteamAPI_ISteamInventory_GetResultItemProperty)
|
GET_ORIGINAL_FUNCTION(SteamAPI_ISteamInventory_GetResultItemProperty)
|
||||||
|
|
||||||
return SteamAPI_ISteamInventory_GetResultItemProperty_o(
|
return SteamAPI_ISteamInventory_GetResultItemProperty_o(
|
||||||
self, resultHandle, unItemIndex, pchPropertyName, pchValueBuffer, punValueBufferSizeOut
|
self, resultHandle, unItemIndex, pchPropertyName, pchValueBuffer, punValueBufferSizeOut
|
||||||
@@ -126,7 +126,7 @@ DLL_EXPORT(bool) SteamAPI_ISteamInventory_CheckResultSteamID(
|
|||||||
CSteamID steamIDExpected
|
CSteamID steamIDExpected
|
||||||
) {
|
) {
|
||||||
return steam_inventory::CheckResultSteamID(__func__, resultHandle, steamIDExpected, [&]() {
|
return steam_inventory::CheckResultSteamID(__func__, resultHandle, steamIDExpected, [&]() {
|
||||||
GET_ORIGINAL_VIRTUAL_FUNCTION(SteamAPI_ISteamInventory_CheckResultSteamID)
|
GET_ORIGINAL_FUNCTION(SteamAPI_ISteamInventory_CheckResultSteamID)
|
||||||
|
|
||||||
return SteamAPI_ISteamInventory_CheckResultSteamID_o(self, resultHandle, steamIDExpected);
|
return SteamAPI_ISteamInventory_CheckResultSteamID_o(self, resultHandle, steamIDExpected);
|
||||||
});
|
});
|
||||||
@@ -180,21 +180,3 @@ DLL_EXPORT(bool) SteamAPI_ISteamInventory_GetItemDefinitionIDs(
|
|||||||
return SteamAPI_ISteamInventory_GetItemDefinitionIDs_o(self, pItemDefIDs, punItemDefIDsArraySize);
|
return SteamAPI_ISteamInventory_GetItemDefinitionIDs_o(self, pItemDefIDs, punItemDefIDsArraySize);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
DLL_EXPORT(bool) SteamAPI_ISteamInventory_GetItemDefinitionProperty(
|
|
||||||
ISteamInventory* self,
|
|
||||||
SteamItemDef_t iDefinition,
|
|
||||||
const char* pchPropertyName,
|
|
||||||
char* pchValueBuffer,
|
|
||||||
uint32_t* punValueBufferSizeOut
|
|
||||||
) {
|
|
||||||
return steam_inventory::GetItemDefinitionProperty(
|
|
||||||
__func__, iDefinition, pchPropertyName, pchValueBuffer, punValueBufferSizeOut, [&]() {
|
|
||||||
GET_ORIGINAL_FUNCTION(SteamAPI_ISteamInventory_GetItemDefinitionProperty)
|
|
||||||
|
|
||||||
return SteamAPI_ISteamInventory_GetItemDefinitionProperty_o(
|
|
||||||
self, iDefinition, pchPropertyName, pchValueBuffer, punValueBufferSizeOut
|
|
||||||
);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -4,15 +4,15 @@
|
|||||||
using namespace smoke_api;
|
using namespace smoke_api;
|
||||||
|
|
||||||
VIRTUAL(bool) ISteamApps_BIsSubscribedApp(PARAMS(AppId_t appID)) { // NOLINT(misc-unused-parameters)
|
VIRTUAL(bool) ISteamApps_BIsSubscribedApp(PARAMS(AppId_t appID)) { // NOLINT(misc-unused-parameters)
|
||||||
return steam_apps::IsSubscribedApp(__func__, appID);
|
return steam_apps::IsDlcUnlocked(__func__, 0, appID);
|
||||||
}
|
}
|
||||||
|
|
||||||
VIRTUAL(bool) ISteamApps_BIsDlcInstalled(PARAMS(AppId_t appID)) { // NOLINT(misc-unused-parameters)
|
VIRTUAL(bool) ISteamApps_BIsDlcInstalled(PARAMS(AppId_t appID)) { // NOLINT(misc-unused-parameters)
|
||||||
return steam_apps::IsDlcInstalled(__func__, appID);
|
return steam_apps::IsDlcUnlocked(__func__, 0, appID);
|
||||||
}
|
}
|
||||||
|
|
||||||
VIRTUAL(int) ISteamApps_GetDLCCount(PARAMS()) {
|
VIRTUAL(int) ISteamApps_GetDLCCount(PARAMS()) {
|
||||||
return steam_apps::GetDLCCount(__func__, [&]() {
|
return steam_apps::GetDLCCount(__func__, 0, [&]() {
|
||||||
GET_ORIGINAL_VIRTUAL_FUNCTION(ISteamApps_GetDLCCount)
|
GET_ORIGINAL_VIRTUAL_FUNCTION(ISteamApps_GetDLCCount)
|
||||||
|
|
||||||
return ISteamApps_GetDLCCount_o(ARGS());
|
return ISteamApps_GetDLCCount_o(ARGS());
|
||||||
@@ -28,7 +28,7 @@ VIRTUAL(bool) ISteamApps_BGetDLCDataByIndex(
|
|||||||
int cchNameBufferSize
|
int cchNameBufferSize
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
return steam_apps::GetDLCDataByIndex(__func__, iDLC, pAppID, pbAvailable, pchName, cchNameBufferSize, [&]() {
|
return steam_apps::GetDLCDataByIndex(__func__, 0, iDLC, pAppID, pbAvailable, pchName, cchNameBufferSize, [&]() {
|
||||||
GET_ORIGINAL_VIRTUAL_FUNCTION(ISteamApps_BGetDLCDataByIndex)
|
GET_ORIGINAL_VIRTUAL_FUNCTION(ISteamApps_BGetDLCDataByIndex)
|
||||||
|
|
||||||
return ISteamApps_BGetDLCDataByIndex_o(
|
return ISteamApps_BGetDLCDataByIndex_o(
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ VIRTUAL(bool) ISteamInventory_GetResultItemProperty(
|
|||||||
uint32_t unItemIndex,
|
uint32_t unItemIndex,
|
||||||
const char* pchPropertyName,
|
const char* pchPropertyName,
|
||||||
char* pchValueBuffer,
|
char* pchValueBuffer,
|
||||||
const uint32_t* punValueBufferSizeOut
|
uint32_t * punValueBufferSizeOut
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
return steam_inventory::GetResultItemProperty(
|
return steam_inventory::GetResultItemProperty(
|
||||||
@@ -115,27 +115,3 @@ VIRTUAL(bool) ISteamInventory_GetItemDefinitionIDs(
|
|||||||
return ISteamInventory_GetItemDefinitionIDs_o(ARGS(pItemDefIDs, punItemDefIDsArraySize));
|
return ISteamInventory_GetItemDefinitionIDs_o(ARGS(pItemDefIDs, punItemDefIDsArraySize));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
VIRTUAL(bool) ISteamInventory_GetItemDefinitionProperty(
|
|
||||||
PARAMS(
|
|
||||||
SteamItemDef_t iDefinition,
|
|
||||||
const char* pchPropertyName,
|
|
||||||
char* pchValueBuffer,
|
|
||||||
uint32_t * punValueBufferSizeOut
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
return steam_inventory::GetItemDefinitionProperty(
|
|
||||||
__func__, iDefinition, pchPropertyName, pchValueBuffer, punValueBufferSizeOut, [&]() {
|
|
||||||
GET_ORIGINAL_VIRTUAL_FUNCTION(ISteamInventory_GetItemDefinitionProperty)
|
|
||||||
|
|
||||||
return ISteamInventory_GetItemDefinitionProperty_o(
|
|
||||||
ARGS(
|
|
||||||
iDefinition,
|
|
||||||
pchPropertyName,
|
|
||||||
pchValueBuffer,
|
|
||||||
punValueBufferSizeOut
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -67,15 +67,14 @@ namespace steam_functions {
|
|||||||
};
|
};
|
||||||
|
|
||||||
FunctionOrdinalMap steam_inventory_ordinal_map = { // NOLINT(cert-err58-cpp)
|
FunctionOrdinalMap steam_inventory_ordinal_map = { // NOLINT(cert-err58-cpp)
|
||||||
{"ISteamInventory_GetResultStatus", {{1, 0}}},
|
{"ISteamInventory_GetResultStatus", {{1, 0}}},
|
||||||
{"ISteamInventory_GetResultItems", {{1, 1}}},
|
{"ISteamInventory_GetResultItems", {{1, 1}}},
|
||||||
{"ISteamInventory_GetResultItemProperty", {{2, 2}}},
|
{"ISteamInventory_GetResultItemProperty", {{2, 2}}},
|
||||||
{"ISteamInventory_CheckResultSteamID", {{1, 3}, {2, 4}}},
|
{"ISteamInventory_CheckResultSteamID", {{1, 3}, {2, 4}}},
|
||||||
{"ISteamInventory_GetAllItems", {{1, 5}, {2, 6}}},
|
{"ISteamInventory_GetAllItems", {{1, 5}, {2, 6}}},
|
||||||
{"ISteamInventory_GetItemsByID", {{1, 6}, {2, 7}}},
|
{"ISteamInventory_GetItemsByID", {{1, 6}, {2, 7}}},
|
||||||
{"ISteamInventory_SerializeResult", {{1, 7}, {2, 8}}},
|
{"ISteamInventory_SerializeResult", {{1, 7}, {2, 8}}},
|
||||||
{"ISteamInventory_GetItemDefinitionIDs", {{1, 20}, {2, 21}}},
|
{"ISteamInventory_GetItemDefinitionIDs", {{1, 20}, {2, 21}}},
|
||||||
{"ISteamInventory_GetItemDefinitionProperty", {{1, 21}, {2, 22}}},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
int extract_version_number(
|
int extract_version_number(
|
||||||
@@ -139,9 +138,11 @@ namespace steam_functions {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Set<void*> hooked_interfaces;
|
static Set<std::pair<void*, String>> hooked_interfaces;
|
||||||
|
|
||||||
if (hooked_interfaces.contains(interface)) {
|
const auto interface_pair = std::pair{interface, version_string};
|
||||||
|
|
||||||
|
if (hooked_interfaces.contains(interface_pair)) {
|
||||||
// This interface is already hooked. Skipping it.
|
// This interface is already hooked. Skipping it.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -189,7 +190,6 @@ namespace steam_functions {
|
|||||||
HOOK_STEAM_INVENTORY(ISteamInventory_GetItemsByID)
|
HOOK_STEAM_INVENTORY(ISteamInventory_GetItemsByID)
|
||||||
HOOK_STEAM_INVENTORY(ISteamInventory_SerializeResult)
|
HOOK_STEAM_INVENTORY(ISteamInventory_SerializeResult)
|
||||||
HOOK_STEAM_INVENTORY(ISteamInventory_GetItemDefinitionIDs)
|
HOOK_STEAM_INVENTORY(ISteamInventory_GetItemDefinitionIDs)
|
||||||
HOOK_STEAM_INVENTORY(ISteamInventory_GetItemDefinitionProperty)
|
|
||||||
|
|
||||||
if (version_number >= 2) {
|
if (version_number >= 2) {
|
||||||
HOOK_STEAM_INVENTORY(ISteamInventory_GetResultItemProperty)
|
HOOK_STEAM_INVENTORY(ISteamInventory_GetResultItemProperty)
|
||||||
@@ -198,7 +198,7 @@ namespace steam_functions {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
hooked_interfaces.insert(interface);
|
hooked_interfaces.insert(interface_pair);
|
||||||
}
|
}
|
||||||
|
|
||||||
HSteamPipe get_steam_pipe_or_throw() {
|
HSteamPipe get_steam_pipe_or_throw() {
|
||||||
|
|||||||
@@ -74,13 +74,12 @@ VIRTUAL(EUserHasLicenseForAppResult) ISteamUser_UserHasLicenseForApp(PARAMS(CSte
|
|||||||
VIRTUAL(EResult) ISteamInventory_GetResultStatus(PARAMS(uint32_t));
|
VIRTUAL(EResult) ISteamInventory_GetResultStatus(PARAMS(uint32_t));
|
||||||
VIRTUAL(bool) ISteamInventory_GetResultItems(PARAMS(SteamInventoryResult_t, SteamItemDetails_t*, uint32_t*));
|
VIRTUAL(bool) ISteamInventory_GetResultItems(PARAMS(SteamInventoryResult_t, SteamItemDetails_t*, uint32_t*));
|
||||||
VIRTUAL(bool) ISteamInventory_GetResultItemProperty(
|
VIRTUAL(bool) ISteamInventory_GetResultItemProperty(
|
||||||
PARAMS(SteamInventoryResult_t, uint32_t, const char*, char*, const uint32_t*)
|
PARAMS(SteamInventoryResult_t, uint32_t, const char*, char*, uint32_t*)
|
||||||
);
|
);
|
||||||
VIRTUAL(bool) ISteamInventory_GetAllItems(PARAMS(SteamInventoryResult_t*));
|
VIRTUAL(bool) ISteamInventory_GetAllItems(PARAMS(SteamInventoryResult_t*));
|
||||||
VIRTUAL(bool) ISteamInventory_GetItemsByID(PARAMS(SteamInventoryResult_t*, const SteamItemInstanceID_t*, uint32_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_SerializeResult(PARAMS(SteamInventoryResult_t, void*, uint32_t*));
|
||||||
VIRTUAL(bool) ISteamInventory_GetItemDefinitionIDs(PARAMS(SteamItemDef_t*, uint32_t*));
|
VIRTUAL(bool) ISteamInventory_GetItemDefinitionIDs(PARAMS(SteamItemDef_t*, uint32_t*));
|
||||||
VIRTUAL(bool) ISteamInventory_GetItemDefinitionProperty(PARAMS(SteamItemDef_t, const char*, char*, uint32_t*));
|
|
||||||
VIRTUAL(bool) ISteamInventory_CheckResultSteamID(PARAMS(SteamInventoryResult_t, CSteamID));
|
VIRTUAL(bool) ISteamInventory_CheckResultSteamID(PARAMS(SteamInventoryResult_t, CSteamID));
|
||||||
|
|
||||||
// API
|
// API
|
||||||
@@ -105,7 +104,7 @@ DLL_EXPORT(bool) SteamAPI_ISteamInventory_GetResultItems(
|
|||||||
ISteamInventory*, SteamInventoryResult_t, SteamItemDetails_t*, uint32_t*
|
ISteamInventory*, SteamInventoryResult_t, SteamItemDetails_t*, uint32_t*
|
||||||
);
|
);
|
||||||
DLL_EXPORT(bool) SteamAPI_ISteamInventory_GetResultItemProperty(
|
DLL_EXPORT(bool) SteamAPI_ISteamInventory_GetResultItemProperty(
|
||||||
ISteamInventory*, SteamInventoryResult_t, uint32_t, const char*, char*, const uint32_t*
|
ISteamInventory*, SteamInventoryResult_t, uint32_t, const char*, char*, uint32_t*
|
||||||
);
|
);
|
||||||
DLL_EXPORT(bool) SteamAPI_ISteamInventory_CheckResultSteamID(ISteamInventory*, SteamInventoryResult_t, CSteamID);
|
DLL_EXPORT(bool) SteamAPI_ISteamInventory_CheckResultSteamID(ISteamInventory*, SteamInventoryResult_t, CSteamID);
|
||||||
DLL_EXPORT(bool) SteamAPI_ISteamInventory_GetAllItems(ISteamInventory*, SteamInventoryResult_t*);
|
DLL_EXPORT(bool) SteamAPI_ISteamInventory_GetAllItems(ISteamInventory*, SteamInventoryResult_t*);
|
||||||
@@ -114,13 +113,36 @@ DLL_EXPORT(bool) SteamAPI_ISteamInventory_GetItemsByID(
|
|||||||
);
|
);
|
||||||
DLL_EXPORT(bool) SteamAPI_ISteamInventory_SerializeResult(ISteamInventory*, SteamInventoryResult_t, void*, uint32_t*);
|
DLL_EXPORT(bool) SteamAPI_ISteamInventory_SerializeResult(ISteamInventory*, SteamInventoryResult_t, void*, uint32_t*);
|
||||||
DLL_EXPORT(bool) SteamAPI_ISteamInventory_GetItemDefinitionIDs(ISteamInventory*, SteamItemDef_t*, uint32_t*);
|
DLL_EXPORT(bool) SteamAPI_ISteamInventory_GetItemDefinitionIDs(ISteamInventory*, SteamItemDef_t*, uint32_t*);
|
||||||
DLL_EXPORT(bool) SteamAPI_ISteamInventory_GetItemDefinitionProperty(
|
|
||||||
ISteamInventory*, SteamItemDef_t, const char*, char*, uint32_t*
|
|
||||||
);
|
|
||||||
|
|
||||||
// vstdlib
|
// Koalageddon mode
|
||||||
|
|
||||||
DLL_EXPORT(HCoroutine) Coroutine_Create(void* callback_address, struct CoroutineData* data);
|
DLL_EXPORT(HCoroutine) Coroutine_Create(void* callback_address, struct CoroutineData* data);
|
||||||
|
DLL_EXPORT(void) Log_Interface(const char* interface_name, const char* function_name);
|
||||||
|
|
||||||
|
// IClientApps
|
||||||
|
VIRTUAL(int) IClientApps_GetDLCCount(PARAMS(AppId_t));
|
||||||
|
VIRTUAL(bool) IClientApps_BGetDLCDataByIndex(PARAMS(AppId_t, int, AppId_t*, bool*, char*, int));
|
||||||
|
|
||||||
|
// IClientAppManager
|
||||||
|
VIRTUAL(bool) IClientAppManager_IsAppDlcInstalled(PARAMS(AppId_t, AppId_t));
|
||||||
|
|
||||||
|
// IClientUser
|
||||||
|
VIRTUAL(bool) IClientUser_IsSubscribedApp(PARAMS(AppId_t));
|
||||||
|
|
||||||
|
// IClientInventory
|
||||||
|
VIRTUAL(EResult) IClientInventory_GetResultStatus(PARAMS(SteamInventoryResult_t));
|
||||||
|
VIRTUAL(bool) IClientInventory_GetResultItems(
|
||||||
|
PARAMS(SteamInventoryResult_t, SteamItemDetails_t*, uint32_t, uint32_t *)
|
||||||
|
);
|
||||||
|
//////
|
||||||
|
VIRTUAL(bool) IClientInventory_GetResultItemProperty(
|
||||||
|
PARAMS(SteamInventoryResult_t, uint32_t, const char*, char*, uint32_t, uint32_t*)
|
||||||
|
);
|
||||||
|
VIRTUAL(bool) IClientInventory_CheckResultSteamID(PARAMS(SteamInventoryResult_t, CSteamID));
|
||||||
|
VIRTUAL(bool) IClientInventory_GetAllItems(PARAMS(SteamInventoryResult_t*));
|
||||||
|
VIRTUAL(bool) IClientInventory_GetItemsByID(PARAMS(SteamInventoryResult_t*, const SteamItemInstanceID_t*, uint32_t));
|
||||||
|
VIRTUAL(bool) IClientInventory_SerializeResult(PARAMS(SteamInventoryResult_t, void*, uint32_t, uint32_t *));
|
||||||
|
VIRTUAL(bool) IClientInventory_GetItemDefinitionIDs(PARAMS(SteamItemDef_t*, uint32_t, uint32_t *));
|
||||||
|
|
||||||
namespace steam_functions {
|
namespace steam_functions {
|
||||||
using namespace koalabox;
|
using namespace koalabox;
|
||||||
|
|||||||
@@ -51,14 +51,15 @@ void save_to_cache(const String& app_id_str) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void fetch_and_cache_dlcs() {
|
void fetch_and_cache_dlcs(AppId_t app_id) {
|
||||||
uint32_t app_id;
|
if (not app_id) {
|
||||||
try {
|
try {
|
||||||
app_id = steam_functions::get_app_id_or_throw();
|
app_id = steam_functions::get_app_id_or_throw();
|
||||||
logger->info("Detected App ID: {}", app_id);
|
logger->info("Detected App ID: {}", app_id);
|
||||||
} catch (const Exception& ex) {
|
} catch (const Exception& ex) {
|
||||||
logger->error("Failed to get app ID: {}", ex.what());
|
logger->error("Failed to get app ID: {}", ex.what());
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto app_id_str = std::to_string(app_id);
|
const auto app_id_str = std::to_string(app_id);
|
||||||
@@ -131,30 +132,32 @@ void fetch_and_cache_dlcs() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String get_app_id_log(const AppId_t app_id) {
|
||||||
|
return app_id ? fmt::format("App ID: {}, ", app_id) : "";
|
||||||
|
}
|
||||||
|
|
||||||
namespace steam_apps{
|
namespace steam_apps {
|
||||||
|
|
||||||
bool IsSubscribedApp(const String& function_name, AppId_t appID) {
|
bool IsDlcUnlocked(const String& function_name, AppId_t app_id, AppId_t dlc_id) {
|
||||||
const auto subscribed = should_unlock(appID);
|
const auto app_id_unlocked = not app_id or should_unlock(app_id); // true if app_id == 0
|
||||||
|
const auto dlc_id_unlocked = should_unlock(dlc_id);
|
||||||
|
|
||||||
logger->info("{} -> App ID: {}, Subscribed: {}", function_name, appID, subscribed);
|
const auto installed = app_id_unlocked and dlc_id_unlocked;
|
||||||
|
|
||||||
return subscribed;
|
logger->info("{} -> {}DLC ID: {}, Unlocked: {}", function_name, get_app_id_log(app_id), dlc_id, installed);
|
||||||
}
|
|
||||||
|
|
||||||
bool IsDlcInstalled(const String& function_name, AppId_t appID) {
|
|
||||||
const auto installed = should_unlock(appID);
|
|
||||||
|
|
||||||
logger->info("{} -> App ID: {}, Installed: {}", function_name, appID, installed);
|
|
||||||
|
|
||||||
return installed;
|
return installed;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetDLCCount(const String& function_name, const std::function<int()>& original_function) {
|
int GetDLCCount(const String& function_name, const AppId_t app_id, const std::function<int()>& original_function) {
|
||||||
static std::mutex section;
|
static std::mutex section;
|
||||||
std::lock_guard<std::mutex> guard(section);
|
std::lock_guard<std::mutex> guard(section);
|
||||||
|
|
||||||
// Compute count only once
|
if (app_id) {
|
||||||
|
logger->debug("{} -> App ID: {}", function_name, app_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compute count only once // FIXME: This doesn't work in Koalageddon mode
|
||||||
static int total_count = [&]() {
|
static int total_count = [&]() {
|
||||||
original_dlc_count = original_function();
|
original_dlc_count = original_function();
|
||||||
logger->debug("{} -> Original DLC count: {}", function_name, original_dlc_count);
|
logger->debug("{} -> Original DLC count: {}", function_name, original_dlc_count);
|
||||||
@@ -171,7 +174,7 @@ namespace steam_apps{
|
|||||||
}
|
}
|
||||||
|
|
||||||
logger->debug("Game has {} or more DLCs. Fetching DLCs from a web API.", max_dlc);
|
logger->debug("Game has {} or more DLCs. Fetching DLCs from a web API.", max_dlc);
|
||||||
fetch_and_cache_dlcs();
|
fetch_and_cache_dlcs(app_id);
|
||||||
|
|
||||||
const auto fetched_count = static_cast<int>(cached_dlcs.size());
|
const auto fetched_count = static_cast<int>(cached_dlcs.size());
|
||||||
logger->debug("{} -> Fetched/cached DLC count: {}", function_name, fetched_count);
|
logger->debug("{} -> Fetched/cached DLC count: {}", function_name, fetched_count);
|
||||||
@@ -186,8 +189,9 @@ namespace steam_apps{
|
|||||||
|
|
||||||
bool GetDLCDataByIndex(
|
bool GetDLCDataByIndex(
|
||||||
const String& function_name,
|
const String& function_name,
|
||||||
|
AppId_t app_id,
|
||||||
int iDLC,
|
int iDLC,
|
||||||
AppId_t* pAppID,
|
AppId_t* pDlcId,
|
||||||
bool* pbAvailable,
|
bool* pbAvailable,
|
||||||
char* pchName,
|
char* pchName,
|
||||||
int cchNameBufferSize,
|
int cchNameBufferSize,
|
||||||
@@ -195,13 +199,13 @@ namespace steam_apps{
|
|||||||
) {
|
) {
|
||||||
const auto print_dlc_info = [&](const String& tag) {
|
const auto print_dlc_info = [&](const String& tag) {
|
||||||
logger->info(
|
logger->info(
|
||||||
"{} -> [{}] index: {}, App ID: {}, available: {}, name: '{}'",
|
"{} -> [{}] {}index: {}, DLC ID: {}, available: {}, name: '{}'",
|
||||||
function_name, tag, iDLC, *pAppID, *pbAvailable, pchName
|
function_name, tag, get_app_id_log(app_id), iDLC, *pDlcId, *pbAvailable, pchName
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto fill_dlc_info = [&](const AppId_t id) {
|
const auto fill_dlc_info = [&](const AppId_t id) {
|
||||||
*pAppID = id;
|
*pDlcId = id;
|
||||||
*pbAvailable = should_unlock(id);
|
*pbAvailable = should_unlock(id);
|
||||||
|
|
||||||
auto name = fmt::format("DLC #{} with ID: {} ", iDLC, id);
|
auto name = fmt::format("DLC #{} with ID: {} ", iDLC, id);
|
||||||
@@ -216,8 +220,8 @@ namespace steam_apps{
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto app_id = config.dlc_ids[index];
|
const auto dlc_id = config.dlc_ids[index];
|
||||||
fill_dlc_info(app_id);
|
fill_dlc_info(dlc_id);
|
||||||
print_dlc_info("injected");
|
print_dlc_info("injected");
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
@@ -229,7 +233,7 @@ namespace steam_apps{
|
|||||||
const auto success = original_function();
|
const auto success = original_function();
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
*pbAvailable = should_unlock(*pAppID);
|
*pbAvailable = should_unlock(*pDlcId);
|
||||||
print_dlc_info("original");
|
print_dlc_info("original");
|
||||||
} else {
|
} else {
|
||||||
logger->warn("{} -> original function failed for index: {}", function_name, iDLC);
|
logger->warn("{} -> original function failed for index: {}", function_name, iDLC);
|
||||||
@@ -254,8 +258,8 @@ namespace steam_apps{
|
|||||||
|
|
||||||
// Cached index
|
// Cached index
|
||||||
if (iDLC < cached_dlcs.size()) {
|
if (iDLC < cached_dlcs.size()) {
|
||||||
const auto app_id = cached_dlcs[iDLC];
|
const auto dlc_id = cached_dlcs[iDLC];
|
||||||
fill_dlc_info(app_id);
|
fill_dlc_info(dlc_id);
|
||||||
print_dlc_info("cached");
|
print_dlc_info("cached");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,16 +4,15 @@ using namespace koalabox;
|
|||||||
|
|
||||||
namespace steam_apps {
|
namespace steam_apps {
|
||||||
|
|
||||||
bool IsSubscribedApp(const String& function_name, AppId_t appID);
|
bool IsDlcUnlocked(const String& function_name, AppId_t app_id, AppId_t dlc_id);
|
||||||
|
|
||||||
bool IsDlcInstalled(const String& function_name, AppId_t appID);
|
int GetDLCCount(const String& function_name, AppId_t app_id, const std::function<int()>& original_function);
|
||||||
|
|
||||||
int GetDLCCount(const String& function_name, const std::function<int()>& original_function);
|
|
||||||
|
|
||||||
bool GetDLCDataByIndex(
|
bool GetDLCDataByIndex(
|
||||||
const String& function_name,
|
const String& function_name,
|
||||||
|
AppId_t app_id,
|
||||||
int iDLC,
|
int iDLC,
|
||||||
AppId_t* pAppID,
|
AppId_t* pDlcId,
|
||||||
bool* pbAvailable,
|
bool* pbAvailable,
|
||||||
char* pchName,
|
char* pchName,
|
||||||
int cchNameBufferSize,
|
int cchNameBufferSize,
|
||||||
@@ -65,7 +64,7 @@ namespace steam_inventory {
|
|||||||
uint32_t unItemIndex,
|
uint32_t unItemIndex,
|
||||||
const char* pchPropertyName,
|
const char* pchPropertyName,
|
||||||
char* pchValueBuffer,
|
char* pchValueBuffer,
|
||||||
const uint32_t* punValueBufferSizeOut,
|
uint32_t* punValueBufferSizeOut,
|
||||||
const std::function<bool()>& original_function
|
const std::function<bool()>& original_function
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -98,14 +97,6 @@ namespace steam_inventory {
|
|||||||
const std::function<bool()>& original_function
|
const std::function<bool()>& original_function
|
||||||
);
|
);
|
||||||
|
|
||||||
bool GetItemDefinitionProperty(
|
|
||||||
const String& function_name,
|
|
||||||
SteamItemDef_t iDefinition,
|
|
||||||
const char* pchPropertyName,
|
|
||||||
char* pchValueBuffer,
|
|
||||||
const uint32_t* punValueBufferSizeOut,
|
|
||||||
const std::function<bool()>& original_function
|
|
||||||
);
|
|
||||||
|
|
||||||
bool CheckResultSteamID(
|
bool CheckResultSteamID(
|
||||||
const String& function_name,
|
const String& function_name,
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ namespace steam_inventory {
|
|||||||
uint32_t unItemIndex,
|
uint32_t unItemIndex,
|
||||||
const char* pchPropertyName,
|
const char* pchPropertyName,
|
||||||
char* pchValueBuffer,
|
char* pchValueBuffer,
|
||||||
const uint32_t* punValueBufferSizeOut,
|
uint32_t* punValueBufferSizeOut,
|
||||||
const std::function<bool()>& original_function
|
const std::function<bool()>& original_function
|
||||||
) {
|
) {
|
||||||
const auto common_info = fmt::format(
|
const auto common_info = fmt::format(
|
||||||
@@ -210,37 +210,13 @@ namespace steam_inventory {
|
|||||||
if (pItemDefIDs) { // Definitions were copied
|
if (pItemDefIDs) { // Definitions were copied
|
||||||
for (int i = 0; i < *punItemDefIDsArraySize; i++) {
|
for (int i = 0; i < *punItemDefIDsArraySize; i++) {
|
||||||
const auto& def = pItemDefIDs[i];
|
const auto& def = pItemDefIDs[i];
|
||||||
logger->debug(" Index: {}, ID: {}", i, def);
|
logger->debug(" Index: {}, ID: {}", i, def);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GetItemDefinitionProperty(
|
|
||||||
const String& function_name,
|
|
||||||
SteamItemDef_t iDefinition,
|
|
||||||
const char* pchPropertyName,
|
|
||||||
char* pchValueBuffer,
|
|
||||||
const uint32_t* punValueBufferSizeOut,
|
|
||||||
const std::function<bool()>& original_function
|
|
||||||
) {
|
|
||||||
const auto common_info = fmt::format(
|
|
||||||
"{} -> Definition ID: {}, Name: '{}'", function_name, iDefinition, pchPropertyName
|
|
||||||
);
|
|
||||||
|
|
||||||
const auto success = original_function();
|
|
||||||
|
|
||||||
if (!success) {
|
|
||||||
logger->warn("{}, Result is false", common_info);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
logger->debug("{}, Buffer: '{}'", common_info, String(pchValueBuffer, *punValueBufferSizeOut - 1));
|
|
||||||
|
|
||||||
return success;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CheckResultSteamID(
|
bool CheckResultSteamID(
|
||||||
const String& function_name,
|
const String& function_name,
|
||||||
SteamInventoryResult_t resultHandle,
|
SteamInventoryResult_t resultHandle,
|
||||||
|
|||||||
13
src/steamclient_virtuals/client_app_manager.cpp
Normal file
13
src/steamclient_virtuals/client_app_manager.cpp
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
#include <smoke_api/smoke_api.hpp>
|
||||||
|
#include <steam_impl/steam_impl.hpp>
|
||||||
|
|
||||||
|
using namespace smoke_api;
|
||||||
|
|
||||||
|
VIRTUAL(bool) IClientAppManager_IsAppDlcInstalled(
|
||||||
|
PARAMS( // NOLINT(misc-unused-parameters)
|
||||||
|
AppId_t app_id,
|
||||||
|
AppId_t dlc_id
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
return steam_apps::IsDlcUnlocked(__func__, app_id, dlc_id);
|
||||||
|
}
|
||||||
31
src/steamclient_virtuals/client_apps.cpp
Normal file
31
src/steamclient_virtuals/client_apps.cpp
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
#include <smoke_api/smoke_api.hpp>
|
||||||
|
#include <steam_impl/steam_impl.hpp>
|
||||||
|
|
||||||
|
using namespace smoke_api;
|
||||||
|
|
||||||
|
VIRTUAL(int) IClientApps_GetDLCCount(PARAMS(AppId_t appId)) {
|
||||||
|
return steam_apps::GetDLCCount(__func__, appId, [&]() {
|
||||||
|
GET_ORIGINAL_VIRTUAL_FUNCTION(IClientApps_GetDLCCount)
|
||||||
|
|
||||||
|
return IClientApps_GetDLCCount_o(ARGS(appId));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
VIRTUAL(bool) IClientApps_BGetDLCDataByIndex(
|
||||||
|
PARAMS(
|
||||||
|
AppId_t appID,
|
||||||
|
int iDLC,
|
||||||
|
AppId_t* pDlcID,
|
||||||
|
bool* pbAvailable,
|
||||||
|
char* pchName,
|
||||||
|
int cchNameBufferSize
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
return steam_apps::GetDLCDataByIndex(__func__, appID, iDLC, pDlcID, pbAvailable, pchName, cchNameBufferSize, [&]() {
|
||||||
|
GET_ORIGINAL_VIRTUAL_FUNCTION(IClientApps_BGetDLCDataByIndex)
|
||||||
|
|
||||||
|
return IClientApps_BGetDLCDataByIndex_o(
|
||||||
|
ARGS(appID, iDLC, pDlcID, pbAvailable, pchName, cchNameBufferSize)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
135
src/steamclient_virtuals/client_inventory.cpp
Normal file
135
src/steamclient_virtuals/client_inventory.cpp
Normal file
@@ -0,0 +1,135 @@
|
|||||||
|
#include <smoke_api/smoke_api.hpp>
|
||||||
|
#include <steam_impl/steam_impl.hpp>
|
||||||
|
|
||||||
|
using namespace smoke_api;
|
||||||
|
|
||||||
|
VIRTUAL(EResult) IClientInventory_GetResultStatus(PARAMS(SteamInventoryResult_t resultHandle)) {
|
||||||
|
return steam_inventory::GetResultStatus(__func__, resultHandle, [&]() {
|
||||||
|
GET_ORIGINAL_VIRTUAL_FUNCTION(IClientInventory_GetResultStatus)
|
||||||
|
|
||||||
|
return IClientInventory_GetResultStatus_o(ARGS(resultHandle));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
VIRTUAL(bool) IClientInventory_GetResultItems(
|
||||||
|
PARAMS(
|
||||||
|
SteamInventoryResult_t resultHandle,
|
||||||
|
SteamItemDetails_t* pOutItemsArray, // 1st pass: null, 2nd pass: ptr to out array
|
||||||
|
uint32_t item_count, // 1st pass: 0, 2nd pass: array size
|
||||||
|
uint32_t * punOutItemsArraySize // 1st pass: ptr to out array size, 2nd pass: ptr to 0
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
|
||||||
|
return steam_inventory::GetResultItems(
|
||||||
|
__func__, resultHandle, pOutItemsArray, punOutItemsArraySize,
|
||||||
|
[&]() {
|
||||||
|
GET_ORIGINAL_VIRTUAL_FUNCTION(IClientInventory_GetResultItems)
|
||||||
|
|
||||||
|
*punOutItemsArraySize = item_count;
|
||||||
|
return IClientInventory_GetResultItems_o(
|
||||||
|
ARGS(resultHandle, pOutItemsArray, item_count, punOutItemsArraySize)
|
||||||
|
);
|
||||||
|
},
|
||||||
|
[&](SteamItemDef_t* pItemDefIDs, uint32_t* punItemDefIDsArraySize) {
|
||||||
|
GET_ORIGINAL_VIRTUAL_FUNCTION(IClientInventory_GetItemDefinitionIDs)
|
||||||
|
|
||||||
|
return IClientInventory_GetItemDefinitionIDs_o(
|
||||||
|
ARGS(pItemDefIDs, *punItemDefIDsArraySize, punItemDefIDsArraySize)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Verify this function [ ] signature, in-game [ ]
|
||||||
|
VIRTUAL(bool) IClientInventory_GetResultItemProperty(
|
||||||
|
PARAMS(
|
||||||
|
SteamInventoryResult_t resultHandle,
|
||||||
|
uint32_t unItemIndex,
|
||||||
|
const char* pchPropertyName,
|
||||||
|
char* pchValueBuffer,
|
||||||
|
uint32_t item_count,
|
||||||
|
uint32_t * punValueBufferSizeOut
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
return steam_inventory::GetResultItemProperty(
|
||||||
|
__func__, resultHandle, unItemIndex, pchPropertyName, pchValueBuffer, punValueBufferSizeOut, [&]() {
|
||||||
|
GET_ORIGINAL_VIRTUAL_FUNCTION(IClientInventory_GetResultItemProperty)
|
||||||
|
|
||||||
|
*punValueBufferSizeOut = item_count;
|
||||||
|
return IClientInventory_GetResultItemProperty_o(
|
||||||
|
ARGS(resultHandle, unItemIndex, pchPropertyName, pchValueBuffer, item_count, punValueBufferSizeOut)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Verify this function [x] signature, in-game [ ]
|
||||||
|
VIRTUAL(bool) IClientInventory_CheckResultSteamID(
|
||||||
|
PARAMS(
|
||||||
|
SteamInventoryResult_t resultHandle,
|
||||||
|
CSteamID steamIDExpected
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
return steam_inventory::CheckResultSteamID(__func__, resultHandle, steamIDExpected, [&]() {
|
||||||
|
GET_ORIGINAL_VIRTUAL_FUNCTION(IClientInventory_CheckResultSteamID)
|
||||||
|
|
||||||
|
return IClientInventory_CheckResultSteamID_o(ARGS(resultHandle, steamIDExpected));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// TODO: Verify this function [x] signature, in-game [ ]
|
||||||
|
VIRTUAL(bool) IClientInventory_GetAllItems(PARAMS(SteamInventoryResult_t* pResultHandle)) {
|
||||||
|
return steam_inventory::GetAllItems(__func__, pResultHandle, [&]() {
|
||||||
|
GET_ORIGINAL_VIRTUAL_FUNCTION(IClientInventory_GetAllItems)
|
||||||
|
|
||||||
|
return IClientInventory_GetAllItems_o(ARGS(pResultHandle));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Verify this function [x] signature, in-game [ ]
|
||||||
|
VIRTUAL(bool) IClientInventory_GetItemsByID(
|
||||||
|
PARAMS(
|
||||||
|
SteamInventoryResult_t* pResultHandle,
|
||||||
|
const SteamItemInstanceID_t* pInstanceIDs,
|
||||||
|
uint32_t unCountInstanceIDs
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
return steam_inventory::GetItemsByID(__func__, pResultHandle, pInstanceIDs, unCountInstanceIDs, [&]() {
|
||||||
|
GET_ORIGINAL_VIRTUAL_FUNCTION(IClientInventory_GetItemsByID)
|
||||||
|
|
||||||
|
return IClientInventory_GetItemsByID_o(ARGS(pResultHandle, pInstanceIDs, unCountInstanceIDs));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Verify this function [x] signature, in-game [ ]
|
||||||
|
VIRTUAL(bool) IClientInventory_SerializeResult(
|
||||||
|
PARAMS(
|
||||||
|
SteamInventoryResult_t resultHandle,
|
||||||
|
void* pOutBuffer,
|
||||||
|
uint32_t buffer_size,
|
||||||
|
uint32_t * punOutBufferSize
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
return steam_inventory::SerializeResult(__func__, resultHandle, pOutBuffer, punOutBufferSize, [&]() {
|
||||||
|
GET_ORIGINAL_VIRTUAL_FUNCTION(IClientInventory_SerializeResult)
|
||||||
|
|
||||||
|
*punOutBufferSize = buffer_size;
|
||||||
|
return IClientInventory_SerializeResult_o(ARGS(resultHandle, pOutBuffer, buffer_size, punOutBufferSize));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
VIRTUAL(bool) IClientInventory_GetItemDefinitionIDs(
|
||||||
|
PARAMS(
|
||||||
|
SteamItemDef_t* pItemDefIDs, // 1st pass: null, 2nd pass: ptr to out array
|
||||||
|
uint32_t item_count, // 1st pass: 0, 2nd pass: array size
|
||||||
|
uint32_t * p_array_size // 1st pass: ptr to out array size, 2nd pass: ptr to 0
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
return steam_inventory::GetItemDefinitionIDs(__func__, pItemDefIDs, p_array_size, [&]() {
|
||||||
|
GET_ORIGINAL_VIRTUAL_FUNCTION(IClientInventory_GetItemDefinitionIDs)
|
||||||
|
|
||||||
|
*p_array_size = item_count;
|
||||||
|
return IClientInventory_GetItemDefinitionIDs_o(ARGS(pItemDefIDs, item_count, p_array_size));
|
||||||
|
});
|
||||||
|
}
|
||||||
8
src/steamclient_virtuals/client_user.cpp
Normal file
8
src/steamclient_virtuals/client_user.cpp
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
#include <smoke_api/smoke_api.hpp>
|
||||||
|
#include <steam_impl/steam_impl.hpp>
|
||||||
|
|
||||||
|
using namespace smoke_api;
|
||||||
|
|
||||||
|
VIRTUAL(bool) IClientUser_IsSubscribedApp(PARAMS(AppId_t app_id)) { // NOLINT(misc-unused-parameters)
|
||||||
|
return steam_apps::IsDlcUnlocked(__func__, 0, app_id);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user