diff --git a/CMakeLists.txt b/CMakeLists.txt index 1ecb170..2a667d7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,8 +7,6 @@ include(KoalaBox/cmake/KoalaBox.cmake) add_subdirectory(KoalaBox) add_subdirectory(tools) -configure_build_config(extra_build_config) - set(SMOKE_API_STATIC_SOURCES static/smoke_api/interfaces/steam_apps.hpp static/smoke_api/interfaces/steam_apps.cpp @@ -61,6 +59,8 @@ else() endif() set_32_and_64(SMOKE_API_FILENAME smoke_api32 smoke_api64) +configure_build_config(extra_build_config) + ### SmokeAPI interface add_library(SmokeAPI_common INTERFACE) @@ -109,13 +109,13 @@ if(WIN32) DLL_FILES_GLOB "C:/Windows/System32/version.dll" ) else() - configure_linker_exports( - TARGET SmokeAPI - HEADER_NAME "libsteam_api_exports.cpp" - FORWARDED_DLL "${STEAM_API_MODULE}_o.so" - DLL_FILES_GLOB "${CMAKE_CURRENT_SOURCE_DIR}/res/steamworks/*/binaries/${LINUX_DIR}/${STEAM_API_MODULE}.so" - INPUT_SOURCES_DIR "" - ) +# configure_linker_exports( +# TARGET SmokeAPI +# HEADER_NAME "libsteam_api_exports.cpp" +# FORWARDED_DLL "${STEAM_API_MODULE}_o.so" +# DLL_FILES_GLOB "${CMAKE_CURRENT_SOURCE_DIR}/res/steamworks/*/binaries/${LINUX_DIR}/${STEAM_API_MODULE}.so" +# INPUT_SOURCES_DIR "" +# ) endif() ## https://github.com/batterycenter/embed diff --git a/KoalaBox b/KoalaBox index cbf46eb..cfcce0a 160000 --- a/KoalaBox +++ b/KoalaBox @@ -1 +1 @@ -Subproject commit cbf46eba34491683839ccd23328f00a14a12baca +Subproject commit cfcce0a712c4164ff4a1162d3b7df3729dad959d diff --git a/res/extra_build_config.gen.h b/res/extra_build_config.gen.h index 2a4049f..141a89e 100644 --- a/res/extra_build_config.gen.h +++ b/res/extra_build_config.gen.h @@ -1,4 +1,4 @@ #pragma once -#define STEAMAPI_DLL "${STEAMAPI_DLL}" +#define STEAM_API_MODULE "${STEAM_API_MODULE}" #define STEAMCLIENT_DLL "${STEAMCLIENT_DLL}" diff --git a/src/main_linux.cpp b/src/main_linux.cpp index 0e2100b..d34c3af 100644 --- a/src/main_linux.cpp +++ b/src/main_linux.cpp @@ -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(&on_loaded), &info) && info.dli_fname) { + if(dladdr(reinterpret_cast(&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(); } diff --git a/src/smoke_api/smoke_api.cpp b/src/smoke_api/smoke_api.cpp index acb69ee..4ae41d0 100644 --- a/src/smoke_api/smoke_api.cpp +++ b/src/smoke_api/smoke_api.cpp @@ -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"); diff --git a/src/steam_api/steam_interfaces.cpp b/src/steam_api/steam_interfaces.cpp index e06224d..b4c5de6 100644 --- a/src/steam_api/steam_interfaces.cpp +++ b/src/steam_api/steam_interfaces.cpp @@ -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(); - // 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);