mirror of
https://github.com/acidicoala/SmokeAPI.git
synced 2026-01-30 16:32:51 -05:00
[WIP] Linux support
This commit is contained in:
@@ -7,8 +7,6 @@ include(KoalaBox/cmake/KoalaBox.cmake)
|
|||||||
add_subdirectory(KoalaBox)
|
add_subdirectory(KoalaBox)
|
||||||
add_subdirectory(tools)
|
add_subdirectory(tools)
|
||||||
|
|
||||||
configure_build_config(extra_build_config)
|
|
||||||
|
|
||||||
set(SMOKE_API_STATIC_SOURCES
|
set(SMOKE_API_STATIC_SOURCES
|
||||||
static/smoke_api/interfaces/steam_apps.hpp
|
static/smoke_api/interfaces/steam_apps.hpp
|
||||||
static/smoke_api/interfaces/steam_apps.cpp
|
static/smoke_api/interfaces/steam_apps.cpp
|
||||||
@@ -61,6 +59,8 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
set_32_and_64(SMOKE_API_FILENAME smoke_api32 smoke_api64)
|
set_32_and_64(SMOKE_API_FILENAME smoke_api32 smoke_api64)
|
||||||
|
|
||||||
|
configure_build_config(extra_build_config)
|
||||||
|
|
||||||
### SmokeAPI interface
|
### SmokeAPI interface
|
||||||
|
|
||||||
add_library(SmokeAPI_common INTERFACE)
|
add_library(SmokeAPI_common INTERFACE)
|
||||||
@@ -109,13 +109,13 @@ if(WIN32)
|
|||||||
DLL_FILES_GLOB "C:/Windows/System32/version.dll"
|
DLL_FILES_GLOB "C:/Windows/System32/version.dll"
|
||||||
)
|
)
|
||||||
else()
|
else()
|
||||||
configure_linker_exports(
|
# configure_linker_exports(
|
||||||
TARGET SmokeAPI
|
# TARGET SmokeAPI
|
||||||
HEADER_NAME "libsteam_api_exports.cpp"
|
# HEADER_NAME "libsteam_api_exports.cpp"
|
||||||
FORWARDED_DLL "${STEAM_API_MODULE}_o.so"
|
# FORWARDED_DLL "${STEAM_API_MODULE}_o.so"
|
||||||
DLL_FILES_GLOB "${CMAKE_CURRENT_SOURCE_DIR}/res/steamworks/*/binaries/${LINUX_DIR}/${STEAM_API_MODULE}.so"
|
# DLL_FILES_GLOB "${CMAKE_CURRENT_SOURCE_DIR}/res/steamworks/*/binaries/${LINUX_DIR}/${STEAM_API_MODULE}.so"
|
||||||
INPUT_SOURCES_DIR ""
|
# INPUT_SOURCES_DIR ""
|
||||||
)
|
# )
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
## https://github.com/batterycenter/embed
|
## https://github.com/batterycenter/embed
|
||||||
|
|||||||
2
KoalaBox
2
KoalaBox
Submodule KoalaBox updated: cbf46eba34...cfcce0a712
@@ -1,4 +1,4 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define STEAMAPI_DLL "${STEAMAPI_DLL}"
|
#define STEAM_API_MODULE "${STEAM_API_MODULE}"
|
||||||
#define STEAMCLIENT_DLL "${STEAMCLIENT_DLL}"
|
#define STEAMCLIENT_DLL "${STEAMCLIENT_DLL}"
|
||||||
|
|||||||
@@ -2,11 +2,11 @@
|
|||||||
|
|
||||||
#include "smoke_api/smoke_api.hpp"
|
#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,
|
// On linux we don't automatically get current module handle,
|
||||||
// hence we get it manually
|
// hence we find it manually
|
||||||
Dl_info info;
|
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);
|
void* handle = dlopen(info.dli_fname, RTLD_NOW | RTLD_NOLOAD);
|
||||||
smoke_api::init(handle);
|
smoke_api::init(handle);
|
||||||
} else {
|
} 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();
|
smoke_api::shutdown();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,9 +64,9 @@ namespace {
|
|||||||
bool on_steamclient_loaded(const HMODULE steamclient_handle) {
|
bool on_steamclient_loaded(const HMODULE steamclient_handle) {
|
||||||
auto* const steamapi_handle = original_steamapi_handle
|
auto* const steamapi_handle = original_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) {
|
if(!steamapi_handle) {
|
||||||
LOG_ERROR("{} -> {} is not loaded", __func__, STEAMAPI_DLL);
|
LOG_ERROR("{} -> {} is not loaded", __func__, STEAM_API_MODULE);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,7 +75,7 @@ namespace {
|
|||||||
const auto steamclient_versions = find_steamclient_versions(steamapi_handle);
|
const auto steamclient_versions = find_steamclient_versions(steamapi_handle);
|
||||||
for(const auto& steamclient_version : steamclient_versions) {
|
for(const auto& steamclient_version : steamclient_versions) {
|
||||||
if(CreateInterface$(steamclient_version.c_str(), nullptr)) {
|
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,
|
// Even before initialization, an interface will be returned,
|
||||||
// but GetISteamGenericInterface will still fail.
|
// but GetISteamGenericInterface will still fail.
|
||||||
LOG_WARN("'{}' was already initialized. SmokeAPI might not work as expected.", steamclient_version);
|
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
|
// We need to hook functions in either mode
|
||||||
kb::hook::init(true);
|
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");
|
LOG_INFO("Detected hook mode");
|
||||||
|
|
||||||
start_dll_listener();
|
start_dll_listener();
|
||||||
} else {
|
} else {
|
||||||
LOG_INFO("Detected proxy mode");
|
LOG_INFO("Detected proxy mode");
|
||||||
|
|
||||||
|
start_dll_listener();
|
||||||
|
|
||||||
const auto self_path = kb::paths::get_self_dir();
|
const auto self_path = kb::paths::get_self_dir();
|
||||||
original_steamapi_handle = kb::loader::load_original_library(
|
original_steamapi_handle = kb::loader::load_original_library(
|
||||||
self_path,
|
self_path,
|
||||||
STEAMAPI_DLL
|
STEAM_API_MODULE
|
||||||
);
|
);
|
||||||
|
|
||||||
start_dll_listener();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_INFO("Initialization complete");
|
LOG_INFO("Initialization complete");
|
||||||
|
|||||||
@@ -206,10 +206,10 @@ namespace steam_interfaces {
|
|||||||
// Remove steam client map since we don't want to hook its methods
|
// Remove steam client map since we don't want to hook its methods
|
||||||
virtual_hook_map.erase(STEAM_CLIENT);
|
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>();
|
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 CreateInterface$ = KB_MOD_GET_FUNC(steamclient_handle, CreateInterface);
|
||||||
const auto* const THIS = CreateInterface$(steam_client_interface_version.c_str(), nullptr);
|
const auto* const THIS = CreateInterface$(steam_client_interface_version.c_str(), nullptr);
|
||||||
hook_virtuals(THIS, steam_client_interface_version);
|
hook_virtuals(THIS, steam_client_interface_version);
|
||||||
|
|||||||
Reference in New Issue
Block a user