mirror of
https://github.com/acidicoala/SmokeAPI.git
synced 2026-01-24 21:42:53 -05:00
Refactor
This commit is contained in:
@@ -57,7 +57,7 @@ namespace smoke_api {
|
||||
logger->info("Loaded Koalageddon config from the {}", kg_config_source);
|
||||
|
||||
dll_monitor::init({VSTDLIB_DLL, STEAMCLIENT_DLL}, [](const HMODULE& library, const String& name) {
|
||||
original_library = library; // TODO: Is this necessary?
|
||||
original_library = library;
|
||||
|
||||
if (name == VSTDLIB_DLL) {
|
||||
// Family Sharing functions
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
#include <smoke_api/smoke_api.hpp>
|
||||
#include <steam_impl/steam_impl.hpp>
|
||||
#include <steam_impl/steam_apps.hpp>
|
||||
#include <steam_impl/steam_client.hpp>
|
||||
#include <steam_impl/steam_inventory.hpp>
|
||||
#include <steam_impl/steam_user.hpp>
|
||||
|
||||
using namespace smoke_api;
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#include <smoke_api/smoke_api.hpp>
|
||||
#include <steam_impl/steam_impl.hpp>
|
||||
#include <steam_functions/steam_functions.hpp>
|
||||
#include <steam_impl/steam_client.hpp>
|
||||
|
||||
using namespace smoke_api;
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#include <smoke_api/smoke_api.hpp>
|
||||
#include <steam_impl/steam_impl.hpp>
|
||||
#include <steam_functions/steam_functions.hpp>
|
||||
#include <steam_impl/steam_client.hpp>
|
||||
|
||||
#include <koalabox/win_util.hpp>
|
||||
|
||||
@@ -18,9 +17,9 @@ String get_versioned_interface(const String& version_prefix, const String& fallb
|
||||
|
||||
if (not version_map.contains(version_prefix)) {
|
||||
try {
|
||||
String rdata = win_util::get_pe_section_data_or_throw(original_library, ".rdata");
|
||||
const String rdata = win_util::get_pe_section_data_or_throw(original_library, ".rdata");
|
||||
|
||||
std::regex regex(version_prefix + "\\d{3}");
|
||||
const std::regex regex(version_prefix + "\\d{3}");
|
||||
std::smatch match;
|
||||
if (std::regex_search(rdata, match, regex)) {
|
||||
version_map[version_prefix] = match[0];
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <smoke_api/smoke_api.hpp>
|
||||
#include <steam_impl/steam_impl.hpp>
|
||||
#include <steam_impl/steam_apps.hpp>
|
||||
|
||||
using namespace smoke_api;
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#include <smoke_api/smoke_api.hpp>
|
||||
#include <steam_impl/steam_impl.hpp>
|
||||
#include <steam_functions/steam_functions.hpp>
|
||||
#include <steam_impl/steam_client.hpp>
|
||||
|
||||
using namespace smoke_api;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <smoke_api/smoke_api.hpp>
|
||||
#include <steam_impl/steam_impl.hpp>
|
||||
#include <steam_impl/steam_inventory.hpp>
|
||||
|
||||
using namespace smoke_api;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <smoke_api/smoke_api.hpp>
|
||||
#include <steam_impl/steam_impl.hpp>
|
||||
#include <steam_impl/steam_user.hpp>
|
||||
|
||||
using namespace smoke_api;
|
||||
|
||||
|
||||
@@ -55,6 +55,8 @@ typedef uint64_t CSteamID;
|
||||
|
||||
typedef uint32_t HCoroutine;
|
||||
|
||||
// TODO: Refactor into multiple headers
|
||||
|
||||
// ISteamClient
|
||||
VIRTUAL(void*) ISteamClient_GetISteamApps(PARAMS(HSteamUser, HSteamPipe, const char*));
|
||||
VIRTUAL(void*) ISteamClient_GetISteamUser(PARAMS(HSteamUser, HSteamPipe, const char*));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <smoke_api/smoke_api.hpp>
|
||||
#include <steam_impl/steam_impl.hpp>
|
||||
#include <steam_impl/steam_apps.hpp>
|
||||
|
||||
#include <koalabox/io.hpp>
|
||||
|
||||
@@ -163,8 +163,6 @@ namespace steam_apps {
|
||||
logger->debug("{} -> App ID: {}", function_name, app_id);
|
||||
}
|
||||
|
||||
// Compute count only once
|
||||
// FIXME: This doesn't work in Koalageddon mode
|
||||
original_dlc_count = original_function();
|
||||
logger->debug("{} -> Original DLC count: {}", function_name, original_dlc_count);
|
||||
|
||||
|
||||
22
src/steam_impl/steam_apps.hpp
Normal file
22
src/steam_impl/steam_apps.hpp
Normal file
@@ -0,0 +1,22 @@
|
||||
#include <steam_functions/steam_functions.hpp>
|
||||
|
||||
using namespace smoke_api;
|
||||
|
||||
namespace steam_apps {
|
||||
|
||||
bool IsDlcUnlocked(const String& function_name, AppId_t app_id, AppId_t dlc_id);
|
||||
|
||||
int GetDLCCount(const String& function_name, AppId_t app_id, const std::function<int()>& original_function);
|
||||
|
||||
bool GetDLCDataByIndex(
|
||||
const String& function_name,
|
||||
AppId_t app_id,
|
||||
int iDLC,
|
||||
AppId_t* pDlcId,
|
||||
bool* pbAvailable,
|
||||
char* pchName,
|
||||
int cchNameBufferSize,
|
||||
const std::function<bool()>& original_function
|
||||
);
|
||||
|
||||
}
|
||||
@@ -1,6 +1,9 @@
|
||||
#include <steam_impl/steam_impl.hpp>
|
||||
#include <smoke_api/smoke_api.hpp>
|
||||
#include <steam_functions/steam_functions.hpp>
|
||||
|
||||
namespace steam_client{
|
||||
using namespace smoke_api;
|
||||
|
||||
namespace steam_client {
|
||||
|
||||
void* GetGenericInterface(
|
||||
const String& function_name,
|
||||
|
||||
14
src/steam_impl/steam_client.hpp
Normal file
14
src/steam_impl/steam_client.hpp
Normal file
@@ -0,0 +1,14 @@
|
||||
#include <smoke_api/smoke_api.hpp>
|
||||
#include <steam_functions/steam_functions.hpp>
|
||||
|
||||
using namespace smoke_api;
|
||||
|
||||
namespace steam_client {
|
||||
|
||||
void* GetGenericInterface(
|
||||
const String& function_name,
|
||||
const String& interface_version,
|
||||
const std::function<void*()>& original_function
|
||||
);
|
||||
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <steam_impl/steam_impl.hpp>
|
||||
#include <smoke_api/smoke_api.hpp>
|
||||
#include <steam_impl/steam_inventory.hpp>
|
||||
|
||||
// TODO: Figure out why it doesn't work in koalageddon mode
|
||||
namespace steam_inventory {
|
||||
@@ -25,7 +25,7 @@ namespace steam_inventory {
|
||||
const std::function<bool(SteamItemDef_t*, uint32_t*)>& get_item_definition_ids
|
||||
) {
|
||||
static std::mutex section;
|
||||
std::lock_guard<std::mutex> guard(section);
|
||||
const std::lock_guard<std::mutex> guard(section);
|
||||
|
||||
const auto success = original_function();
|
||||
|
||||
@@ -120,7 +120,7 @@ namespace steam_inventory {
|
||||
uint32_t unItemIndex,
|
||||
const char* pchPropertyName,
|
||||
char* pchValueBuffer,
|
||||
uint32_t* punValueBufferSizeOut,
|
||||
const uint32_t* punValueBufferSizeOut,
|
||||
const std::function<bool()>& original_function
|
||||
) {
|
||||
const auto common_info = fmt::format(
|
||||
|
||||
@@ -1,45 +1,7 @@
|
||||
#include <smoke_api/smoke_api.hpp>
|
||||
#include <steam_functions/steam_functions.hpp>
|
||||
|
||||
using namespace koalabox;
|
||||
|
||||
namespace steam_apps {
|
||||
|
||||
bool IsDlcUnlocked(const String& function_name, AppId_t app_id, AppId_t dlc_id);
|
||||
|
||||
int GetDLCCount(const String& function_name, AppId_t app_id, const std::function<int()>& original_function);
|
||||
|
||||
bool GetDLCDataByIndex(
|
||||
const String& function_name,
|
||||
AppId_t app_id,
|
||||
int iDLC,
|
||||
AppId_t* pDlcId,
|
||||
bool* pbAvailable,
|
||||
char* pchName,
|
||||
int cchNameBufferSize,
|
||||
const std::function<bool()>& original_function
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
namespace steam_user {
|
||||
|
||||
EUserHasLicenseForAppResult UserHasLicenseForApp(
|
||||
const String& function_name,
|
||||
AppId_t appID,
|
||||
const std::function<EUserHasLicenseForAppResult()>& original_function
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
namespace steam_client {
|
||||
|
||||
void* GetGenericInterface(
|
||||
const String& function_name,
|
||||
const String& interface_version,
|
||||
const std::function<void*()>& original_function
|
||||
);
|
||||
|
||||
}
|
||||
using namespace smoke_api;
|
||||
|
||||
namespace steam_inventory {
|
||||
|
||||
@@ -64,7 +26,7 @@ namespace steam_inventory {
|
||||
uint32_t unItemIndex,
|
||||
const char* pchPropertyName,
|
||||
char* pchValueBuffer,
|
||||
uint32_t* punValueBufferSizeOut,
|
||||
const uint32_t* punValueBufferSizeOut,
|
||||
const std::function<bool()>& original_function
|
||||
);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include <steam_impl/steam_impl.hpp>
|
||||
#include <steam_impl/steam_user.hpp>
|
||||
#include <smoke_api/smoke_api.hpp>
|
||||
|
||||
namespace steam_user {
|
||||
|
||||
14
src/steam_impl/steam_user.hpp
Normal file
14
src/steam_impl/steam_user.hpp
Normal file
@@ -0,0 +1,14 @@
|
||||
#include <smoke_api/smoke_api.hpp>
|
||||
#include <steam_functions/steam_functions.hpp>
|
||||
|
||||
using namespace smoke_api;
|
||||
|
||||
namespace steam_user {
|
||||
|
||||
EUserHasLicenseForAppResult UserHasLicenseForApp(
|
||||
const String& function_name,
|
||||
AppId_t appID,
|
||||
const std::function<EUserHasLicenseForAppResult()>& original_function
|
||||
);
|
||||
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
#include <smoke_api/smoke_api.hpp>
|
||||
#include <steam_functions/steam_functions.hpp>
|
||||
#include <steam_impl/steam_impl.hpp>
|
||||
#include <steam_impl/steam_client.hpp>
|
||||
|
||||
using namespace smoke_api;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <smoke_api/smoke_api.hpp>
|
||||
#include <steam_impl/steam_impl.hpp>
|
||||
#include <steam_impl/steam_apps.hpp>
|
||||
|
||||
using namespace smoke_api;
|
||||
|
||||
@@ -10,4 +10,4 @@ VIRTUAL(bool) IClientAppManager_IsAppDlcInstalled(
|
||||
)
|
||||
) {
|
||||
return steam_apps::IsDlcUnlocked(__func__, app_id, dlc_id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <smoke_api/smoke_api.hpp>
|
||||
#include <steam_impl/steam_impl.hpp>
|
||||
#include <steam_impl/steam_apps.hpp>
|
||||
|
||||
using namespace smoke_api;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include <smoke_api/smoke_api.hpp>
|
||||
#include <steam_impl/steam_impl.hpp>
|
||||
#include <steam_impl/steam_inventory.hpp>
|
||||
|
||||
using namespace smoke_api;
|
||||
|
||||
@@ -132,4 +132,4 @@ VIRTUAL(bool) IClientInventory_GetItemDefinitionIDs(
|
||||
*p_array_size = item_count;
|
||||
return IClientInventory_GetItemDefinitionIDs_o(ARGS(pItemDefIDs, item_count, p_array_size));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#include <smoke_api/smoke_api.hpp>
|
||||
#include <steam_impl/steam_impl.hpp>
|
||||
#include <steam_impl/steam_apps.hpp>
|
||||
|
||||
using namespace smoke_api;
|
||||
|
||||
// TODO: Implement?
|
||||
// TODO: Hook?
|
||||
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