[WIP] Linux support

This commit is contained in:
acidicoala
2025-09-14 14:52:16 +05:00
parent 69e7af6dae
commit 51709b53ad
6 changed files with 24 additions and 24 deletions
+4 -4
View File
@@ -2,11 +2,11 @@
#include "smoke_api/smoke_api.hpp"
extern "C" void __attribute__((constructor)) on_loaded() {
extern "C" void __attribute__((constructor)) init() {
// On linux we don't automatically get current module handle,
// hence we get it manually
// hence we find it manually
Dl_info info;
if(dladdr(reinterpret_cast<void*>(&on_loaded), &info) && info.dli_fname) {
if(dladdr(reinterpret_cast<void*>(&init), &info) && info.dli_fname) {
void* handle = dlopen(info.dli_fname, RTLD_NOW | RTLD_NOLOAD);
smoke_api::init(handle);
} else {
@@ -15,6 +15,6 @@ extern "C" void __attribute__((constructor)) on_loaded() {
}
}
extern "C" void __attribute__((destructor)) on_unloaded() {
extern "C" void __attribute__((destructor)) fini() {
smoke_api::shutdown();
}
+7 -7
View File
@@ -64,9 +64,9 @@ namespace {
bool on_steamclient_loaded(const HMODULE steamclient_handle) {
auto* const steamapi_handle = original_steamapi_handle
? original_steamapi_handle
: kb::module::get_library_handle(TEXT(STEAMAPI_DLL));
: kb::module::get_library_handle(TEXT(STEAM_API_MODULE));
if(!steamapi_handle) {
LOG_ERROR("{} -> {} is not loaded", __func__, STEAMAPI_DLL);
LOG_ERROR("{} -> {} is not loaded", __func__, STEAM_API_MODULE);
return true;
}
@@ -75,7 +75,7 @@ namespace {
const auto steamclient_versions = find_steamclient_versions(steamapi_handle);
for(const auto& steamclient_version : steamclient_versions) {
if(CreateInterface$(steamclient_version.c_str(), nullptr)) {
// TODO: This is not true when running under Proton.
// TODO: This is not true when running under Proton or native Linux.
// Even before initialization, an interface will be returned,
// but GetISteamGenericInterface will still fail.
LOG_WARN("'{}' was already initialized. SmokeAPI might not work as expected.", steamclient_version);
@@ -119,20 +119,20 @@ namespace smoke_api {
// We need to hook functions in either mode
kb::hook::init(true);
if(kb::hook::is_hook_mode(module_handle, STEAMAPI_DLL)) {
if(kb::hook::is_hook_mode(module_handle, STEAM_API_MODULE)) {
LOG_INFO("Detected hook mode");
start_dll_listener();
} else {
LOG_INFO("Detected proxy mode");
start_dll_listener();
const auto self_path = kb::paths::get_self_dir();
original_steamapi_handle = kb::loader::load_original_library(
self_path,
STEAMAPI_DLL
STEAM_API_MODULE
);
start_dll_listener();
}
LOG_INFO("Initialization complete");
+2 -2
View File
@@ -206,10 +206,10 @@ namespace steam_interfaces {
// Remove steam client map since we don't want to hook its methods
virtual_hook_map.erase(STEAM_CLIENT);
// Map remaining virtual hook map to a set of keys
// Map virtual hook map to a set of keys
const auto prefixes = std::views::keys(virtual_hook_map) | std::ranges::to<std::set>();
// Prepare HSteamPipe and HSteamUser
const auto CreateInterface$ = KB_MOD_GET_FUNC(steamclient_handle, CreateInterface);
const auto* const THIS = CreateInterface$(steam_client_interface_version.c_str(), nullptr);
hook_virtuals(THIS, steam_client_interface_version);