mirror of https://github.com/acidicoala/SmokeAPI
Refactor
parent
1ba84753aa
commit
0d1ae0fd29
@ -1 +1 @@
|
||||
Subproject commit 21b87810b7bf799b2cb810b3370f1ca751007208
|
||||
Subproject commit d75714857d77790a61d3ef9d27b8afbfa49ccd22
|
@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#define DLL_EXPORT(TYPE) extern "C" [[maybe_unused]] __declspec( dllexport ) TYPE __cdecl
|
||||
#define VIRTUAL(TYPE) __declspec(noinline) TYPE __fastcall
|
||||
|
||||
#define DETOUR(FUNC, ADDRESS) hook::detour_or_warn(ADDRESS, #FUNC, reinterpret_cast<FunctionAddress>(FUNC));
|
||||
#define DETOUR_ORIGINAL(FUNC) DETOUR(FUNC, smoke_api::original_library)
|
@ -0,0 +1,58 @@
|
||||
#include <build_config.h>
|
||||
#include <koalageddon/koalageddon.hpp>
|
||||
#include <smoke_api/smoke_api.hpp>
|
||||
#include <koalabox/dll_monitor.hpp>
|
||||
#include <koalabox/win_util.hpp>
|
||||
#include <koalabox/patcher.hpp>
|
||||
#include <core/macros.hpp>
|
||||
|
||||
namespace koalageddon {
|
||||
KoalageddonConfig config = {};
|
||||
|
||||
/**
|
||||
* @return A string representing the source of the config.
|
||||
*/
|
||||
String init_koalageddon_config() {
|
||||
try {
|
||||
// First try to read a local config override
|
||||
config = smoke_api::config.koalageddon_config.get<KoalageddonConfig>();
|
||||
return "local config override";
|
||||
} catch (const Exception& ex) {
|
||||
logger->debug("Local config parse exception: {}", ex.what());
|
||||
}
|
||||
|
||||
// TODO: Remote source with local cache
|
||||
|
||||
// Finally, fallback on the default config
|
||||
return "default config bundled in the binary";
|
||||
}
|
||||
|
||||
void init() {
|
||||
#ifndef _WIN64
|
||||
logger->info("🐨 Detected Koalageddon mode 💥");
|
||||
|
||||
const auto kg_config_source = init_koalageddon_config();
|
||||
logger->info("Loaded Koalageddon config from the {}", kg_config_source);
|
||||
|
||||
dll_monitor::init({VSTDLIB_DLL, STEAMCLIENT_DLL}, [](const HMODULE& library, const String& name) {
|
||||
smoke_api::original_library = library;
|
||||
|
||||
if (name == VSTDLIB_DLL) {
|
||||
// Family Sharing functions
|
||||
DETOUR_ORIGINAL(Coroutine_Create)
|
||||
} else if (name == STEAMCLIENT_DLL) {
|
||||
// Unlocking functions
|
||||
auto interface_interceptor_address = (FunctionAddress) patcher::find_pattern_address(
|
||||
win_util::get_module_info(library),
|
||||
"SteamClient_Interface_Interceptor",
|
||||
config.interface_interceptor_pattern
|
||||
);
|
||||
|
||||
if (interface_interceptor_address) {
|
||||
DETOUR(SteamClient_Interface_Interceptor, interface_interceptor_address)
|
||||
}
|
||||
}
|
||||
});
|
||||
#endif
|
||||
}
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
#pragma once
|
||||
|
||||
#include <koalabox/koalabox.hpp>
|
||||
#include <core/macros.hpp>
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
namespace koalageddon {
|
||||
using namespace koalabox;
|
||||
|
||||
struct KoalageddonConfig {
|
||||
String interface_interceptor_pattern = "55 8B EC 8B ?? ?? ?? ?? ?? 81 EC ?? ?? ?? ?? 53 FF 15";
|
||||
|
||||
// Offset values are interpreted according to pointer arithmetic rules, i.e.
|
||||
// 1 unit offset represents 4 and 8 bytes in 32-bit and 64-bit architectures respectively.
|
||||
uint32_t callback_interceptor_address_offset = 1;
|
||||
uint32_t callback_address_offset = 20;
|
||||
uint32_t callback_data_offset = 0;
|
||||
uint32_t callback_name_offset = 4;
|
||||
uint32_t steamclient_interceptor_function_address_offset = 2;
|
||||
uint32_t steamclient_interceptor_function_address_offset_client_user = 5;
|
||||
uint32_t IClientAppManager_IsAppDlcInstalled_ordinal = 8;
|
||||
uint32_t IClientApps_GetDLCCount_ordinal = 8;
|
||||
uint32_t IClientApps_BGetDLCDataByIndex_ordinal = 9;
|
||||
uint32_t IClientInventory_GetResultStatus_ordinal = 0;
|
||||
uint32_t IClientInventory_GetResultItems_ordinal = 2;
|
||||
uint32_t IClientInventory_GetResultItemProperty_ordinal = 3;
|
||||
uint32_t IClientInventory_CheckResultSteamID_ordinal = 5;
|
||||
uint32_t IClientInventory_GetAllItems_ordinal = 8;
|
||||
uint32_t IClientInventory_GetItemsByID_ordinal = 9;
|
||||
uint32_t IClientInventory_SerializeResult_ordinal = 6;
|
||||
uint32_t IClientInventory_GetItemDefinitionIDs_ordinal = 19;
|
||||
uint32_t IClientUser_BIsSubscribedApp_ordinal = 191;
|
||||
|
||||
// We do not use *_WITH_DEFAULT macro to ensure that overriding
|
||||
// the koalageddon config requires definition of all keys
|
||||
NLOHMANN_DEFINE_TYPE_INTRUSIVE(
|
||||
KoalageddonConfig, // NOLINT(misc-const-correctness)
|
||||
interface_interceptor_pattern,
|
||||
callback_interceptor_address_offset,
|
||||
callback_address_offset,
|
||||
callback_data_offset,
|
||||
callback_name_offset,
|
||||
steamclient_interceptor_function_address_offset,
|
||||
steamclient_interceptor_function_address_offset_client_user,
|
||||
IClientAppManager_IsAppDlcInstalled_ordinal,
|
||||
IClientApps_GetDLCCount_ordinal,
|
||||
IClientApps_BGetDLCDataByIndex_ordinal,
|
||||
IClientInventory_GetResultStatus_ordinal,
|
||||
IClientInventory_GetResultItems_ordinal,
|
||||
IClientInventory_GetResultItemProperty_ordinal,
|
||||
IClientInventory_CheckResultSteamID_ordinal,
|
||||
IClientInventory_GetAllItems_ordinal,
|
||||
IClientInventory_GetItemsByID_ordinal,
|
||||
IClientInventory_SerializeResult_ordinal,
|
||||
IClientInventory_GetItemDefinitionIDs_ordinal,
|
||||
IClientUser_BIsSubscribedApp_ordinal
|
||||
)
|
||||
};
|
||||
|
||||
extern KoalageddonConfig config;
|
||||
|
||||
void init();
|
||||
}
|
||||
|
||||
typedef uint32_t HCoroutine;
|
||||
|
||||
DLL_EXPORT(HCoroutine) Coroutine_Create(void* callback_address, struct CoroutineData* data);
|
||||
DLL_EXPORT(void) SteamClient_Interface_Interceptor(const char* interface_name, const char* function_name);
|
Loading…
Reference in New Issue